Support

Account

Forum Replies Created

  • This solution didn’t work for me. I made the post author id 1 or the admin and got the same result AFTER spending a LONG time trying to make my “guest author” have the right capabilities without success. I am using CPT UI to make my taxonomies and post types. For not logged in users save_post was my solution…

    Make your own inputs with whatever values you want:

    $htmlAfter = '<input type="hidden" name="tax_name" id="tax_name" value="ENTER_MAIN_TAXONOMY_SLUG">';
    $htmlAfter .= '<input type="hidden" name="tax_slug" id="tax_slug" value="ENTER_INDIVIDUAL_TAXONOMY_SLUG">';

    Add those inputs to acf_form function with html_after_fields parameter (or html_before_fields):

    'html_after_fields' => $htmlAfter

    Save those values ($_POST) as you wish with save_post action:

    function my_acf_save_post( $post_id ) {
        
       if(isset($_POST['tax_name']) && isset($_POST['tax_slug'])) {
    	 wp_set_object_terms( $post_id, $_POST['tax_slug'], $_POST['tax_name'], true );
    	}
        
    }
    
    // run after ACF saves the $_POST['acf'] data
    add_action('acf/save_post', 'my_acf_save_post', 20);
  • $htmlAfter = '<input type="hidden" name="tax_name" id="tax_name" value="ENTER_MAIN_TAXONOMY_SLUG">';
    $htmlAfter .= '<input type="hidden" name="tax_slug" id="tax_slug" value="ENTER_INDIVIDUAL_TAXONOMY_SLUG">';

    'html_after_fields' => $htmlAfter

    function my_acf_save_post( $post_id ) {
        
       if(isset($_POST['tax_name']) && isset($_POST['tax_slug'])) {
    	 wp_set_object_terms( $post_id, $_POST['tax_slug'], $_POST['tax_name'], true );
    	}
        
    }
    
    // run after ACF saves the $_POST['acf'] data
    add_action('acf/save_post', 'my_acf_save_post', 20);

    I know it might not be 100% related, but this idea could be applied in MANY ways, considering where ever you include acf_form, you could use whatever variables are available and then include that data in input values and then include those inputs in the html_after_fields or html_before_fields parameter for the acf_form function.

  • Wanted to give some help. I was stuck on this part for a while to. When you use acf_form() you NEED acf_form_header() FOR SURE if the person is not logged in (unsure about admins logged in)… BUT the save_post method is good. It ISN’T capabilities that is messing it up. I tested to be sure by making the author in acf_form() be the admin (all capabilities) and that didn’t solve the problem. So the save post method is the best BUT then it is hard to get OTHER variables outside the post you created (like from the page you used acf_form() on etc):

    
    $htmlAfter = '<input type="hidden" name="tax_name" id="tax_name" value="ENTER_MAIN_TAXONOMY_SLUG_HERE">';
    	$htmlAfter .= '<input type="hidden" name="tax_slug" id="tax_slug" value="ENTER_INDIVIDUAL_TAXONOMY_SLUG_HERE">';

    Then include it in the acf_form() via the parameter “html_after_fields”:

    'html_after_fields' => $htmlAfter

    THEN, the save_post function:

    function my_acf_save_post( $post_id ) {
        
       if(isset($_POST['tax_name']) && isset($_POST['tax_slug'])) {
    	 wp_set_object_terms( $post_id, $_POST['tax_slug'], $_POST['tax_name'], true );
    	}
        
    }
    
    // run after ACF saves the $_POST['acf'] data
    add_action('acf/save_post', 'my_acf_save_post', 20);
    

    You could enter the values for taxonomy and slug manually or set them as variables conditionally based on whatever you want, where ever you include acf_form() …

  • [show_acf_form id=”item-available-form” field_groups=”924,739″ post_id=”new_post” new_post=”post_type|trading_post,post_status|pending,tax_input|item_type” submit_value=”Submit Item” updated_message=”Updated Message”]

    I am having an issue with tax_input. How would I input that into the shortcode? It is a nested array…

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