• Resolved andyt1980

    (@andyt1980)


    Hi,
    I’m using the filter below to make new form submissions publish posts by default. However, its not working:

    add_filter( ‘cf7_2_post_status_orders’, ‘publish_new_post’,10,3);
    function publish_new_post($status, $ckf7_key, $submitted_data){
    return ‘publish’;
    }

    I’ve checked the name of the post-type and it appears correct.

    Any ideas?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Aurovrata Venet

    (@aurovrata)

    is the function being executed?

    Thread Starter andyt1980

    (@andyt1980)

    How would I check that? I’m presuming its not working because posts are being set as draft still.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    you’ll need to debug your request process.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    I’m presuming its not working because posts are being set as draft still.

    indeed, and likely due to the fact that the function is not being executed due to an error in the way you setup your filter

    Thread Starter andyt1980

    (@andyt1980)

    After checking the debug.log I’m seeing alot of these PHP errors:

    PHP Warning:  Use of undefined constant ‘cf7_2_post_status_orders’ - assumed '‘cf7_2_post_status_orders’' (this will throw an Error in a future version of PHP) in /home/site/public_html/orders/wp-content/themes/hello-elementor-child/functions.php on line 25
    [26-Aug-2021 10:01:22 UTC] PHP Warning:  Use of undefined constant ‘publish_new_post’ - assumed '‘publish_new_post’' (this will throw an Error in a future version of PHP) in /home/site/public_html/orders/wp-content/themes/hello-elementor-child/functions.php on line 25

    Any ideas?

    • This reply was modified 3 years, 6 months ago by andyt1980.
    Plugin Author Aurovrata Venet

    (@aurovrata)

    This is a warning and not an error.

    They are coming from your theme and not from the plugin:

    themes/hello-elementor-child/functions.php on line 25

    so you’ll need to fix those in your file

    Thread Starter andyt1980

    (@andyt1980)

    I’ve removed the offending code from that line and now I’m getting the same error but it references line 166 which is the start of the CF7 filter.

    Can you please double-check if this is correct?:

    add_filter( ‘cf7_2_post_status_orders’, ‘publish_new_post’,10,3);
    function publish_new_post($status, $ckf7_key, $submitted_data){
    return ‘publish’;
    }
    • This reply was modified 3 years, 6 months ago by andyt1980.
    Plugin Author Aurovrata Venet

    (@aurovrata)

    looks like your quotes might be wrongly formatted, try:

    add_filter( "cf7_2_post_status_orders", "publish_new_post",10,3);
    function publish_new_post($status, $ckf7_key, $submitted_data){
    return "publish";
    }
    Plugin Author Aurovrata Venet

    (@aurovrata)

    assumig this worked. Marking this as resolved.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Autopublish Issue’ is closed to new replies.