Support

Account

Forum Replies Created

  • Hi Benbyford,

    Can you share how to integrate ReCaptcha in ACF front-end form?

    I’ve been looking everywhere and still can’t find a reliable one.

    Thank you

  • *Update*

    I successfully create a new post with wp_insert_post function.

    The problem now, I can’t store the CF7 data in a specific ACF field. What should I do?

    Here’s my current function:

    add_action('wpcf7_mail_sent','save_my_form_data_to_my_cpt');
    add_action('wpcf7_mail_failed','save_my_form_data_to_my_cpt');
    
    function save_my_form_data_to_my_cpt($contact_form){
        $submission = WPCF7_Submission::get_instance();
        if (!$submission){
            return;
        }
        $posted_data = $submission->get_posted_data();
    
        $new_post = array();
        $new_post['post_title'] = $posted_data['workshop-title'];
        $new_post['post_type'] = 'my_custom_post_type';
        $new_post['post_content'] = $posted_data['workshop-name'];
        $new_post['post_status'] = 'publish';
    
        //When everything is prepared, insert the post into your WordPress Database
        $post_id = wp_insert_post($new_post))
        return;
    }
  • @hube2 you are really a savior. Thanks for helping.

    There’s a bit typo, but really, you save the day. So for anyone else out there, here’s the functional code:

    # Save the actual time when user click submit
    add_action( 'acf/save_post', 'set_submit_time' );
    function set_submit_time($post_id) {
    	update_field('field_XXXXXX', date('Y-m-d H:i:s'), $post_id);
    }

    You can add within functions.php or your singlepage.php before the acf_form_head();

    Oh and also, if you need to get local time, change the date to this:

    update_field('field_XXXXXX', date('Y-m-d H:i:s', current_time( 'timestamp', 0 )), $post_id);

Viewing 4 posts - 1 through 4 (of 4 total)