Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter webwhalenl

    (@webwhalenl)

    Hi @aurovrata,

    Nope, I didn’t get it working. So I gave up; we will post reviews manually on our website now.

    Thread Starter webwhalenl

    (@webwhalenl)

    Dear Aurovrata,

    Thanks for your reply. So now I’ve added the below code (I replaced post_type) with my own post_type, and I’ve configured this post type in the Post my CF7 form settings.

    
    add_action(‘cf7_2_post_form_mapped_to_webwhale’,’modify_form_posts’,10,2);
    function modify_form_posts($post_id, $cf7_form_data){
    //cf7_form_data is the submitted data from your form
    //post_id is the id of the post to which it has been saved.
    $args = array(
    'ID' => $post_id,
    'post_status' => 'publish'
    );
    wp_update_post($args);
    }
    ?>

    But still, when I post something in the form, the post is still a draft, and not immediately published. Is there something else which I’m doing wrong?

    Your help is really appreciated.

    Thread Starter webwhalenl

    (@webwhalenl)

    Allright, will do. Thanks a lot for the explanation, clarifies a lot.

    Dear Aurovrata,

    Many thanks for your quick reply. I have put that exact piece of code on the bottom of my theme’s functions.php file, however the new posts still appear as drafts.

    Any idea what goes wrong here?

    Best regards,

    Max de Feber

    Dear Aurovrata,

    I’m not very experienced with hooks in WordPress. I also would like to have the new posts published immediately, without first being posted as drafts. If I understand it correctly, from the above messages, the following code needs to be added:

    /**
     * Custom code for instant publishing
     */
    
    add_action(‘cf7_2_post_form_mapped_to_my-cpt’,’modify_form_posts’,10,2);
    function modify_form_posts($post_id, $cf7_form_data){
    //cf7_form_data is the submitted data from your form
    //post_id is the id of the post to which it has been saved.
    $args = array(
    'ID' => $post_id,
    'post_status' => 'publish'
    );
    wp_update_post($args);
    }

    [Moderator note: code fixed. Please wrap code in the backtick character or use the code button.]

    Where do I have to add this code, though?

    Many thanks for helping out!

    Best regards,

    Max de Feber

    • This reply was modified 9 years, 1 month ago by bdbrown.
    • This reply was modified 9 years, 1 month ago by bdbrown.
    Thread Starter webwhalenl

    (@webwhalenl)

    Also, I cannnot update the custom post settings, I get this error message:

    “Something is wrong, try to reload the page”

    Reloading the page, however, doesn’t help.

Viewing 6 replies - 1 through 6 (of 6 total)