• Resolved webwhalenl

    (@webwhalenl)


    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);
    }

    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?

    Many thanks for helping out!

    Best regards,

    Max de Feber

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

    (@aurovrata)

    cf7_2_post_form_mapped_to_my-cpt is an example filter, if you read the original instructions, it lists the filter as: cf7_2_post_form_mapped_to_{$post_type} which means you have to replace the {$post_type} with the post_type you actually configured.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    I’m not very experienced with hooks in WordPress.

    That’s ok, but unfortunately doing advanced forms with CF7 and this plugin requires a fair amount of PHP/HTML/Javascript coding experience and an understanding of hooks.

    In the future, I am add some these hook functionality as checkboxes within the form settings itself, but I just don’t have the time and resources to do this.

    There are some alternative form plugins you could try to use to do similar functionality such as FormidablePro and Gavity Forms, both of which have add-on modules for post mapping. Both of these have Graphical user interface that require very little coding knowledge.

    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.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    This should be enough. Did you check to make sure your function is called properly by printing something in your debug log file from within the function?

    Plugin Author Aurovrata Venet

    (@aurovrata)

    I haven’t heard back from you, so may I assume you finally got it working?

    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.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    do you want me to make it work for you? You can reach me on vrata at syllogic dot in

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Publish posts instantly’ is closed to new replies.