Home Forums Front-end Issues Frontend form for new post not saving taxonomy terms Reply To: Frontend form for new post not saving taxonomy terms

  • Sure! I’m not using the exact code above, just a similar method. Here is the php code i’m using to display the form as well as the custom function.

    The below code works to manually save the taxonomies, but if I remove that portion of the function the taxonomies don’t save.

    NOTE: I have the taxonomy field set to NOT save to the post at the moment just in case it interfered with me doing manually. But when troubleshooting, I had it turned on.
    Also note, there are fields called “columns” which are reliant on another plugin. They just change the layout of the fields and are not important to the actual content of the form.

    On page template:

    <div id="new-audition-form" class="hide-submit">
    				$new_audition = array(
    					'post_id' => 'new_post',
    					'new_post' => array(
    						'post_type' => 'audition',
    						'post_status' => 'draft',
    					'post_title' => true,
    					'post_content' => true,
    					'submit_value' => 'Continue >',
    					'return' => '%post_url%',


    //ACF Front-End Audition Functions
    //Redirect to the terms and conditions page on the first post save
    function tps_acf_save_audition( $post_id ) {
        if (!is_admin()) {
    		// manually update the audition_type taxonomy field
    		$term_object = get_term($_POST['acf']['field_5701d3e794a6f'], 'audition_type');
    		$term_slug = $term_object->slug;
    		wp_set_object_terms($post_id, $term_slug, 'audition_type');
    		if (get_post_status($post_id) == 'draft') {
    // run after ACF saves the $_POST['acf'] data
    add_action('acf/save_post', 'tps_acf_save_audition', 20);

    After the user is redirected to the terms and conditions page, they press a button that publishes the post, completing the process.