• Resolved Zenbirdy

    (@zenbirdy)


    I create a form and add a processor to it (custom fields: save as post type)I have a field to add a taxonomy, when the post is created, even though I can see the taxonomy field, the post is not “tagged” with the taxonomy. I also create a post manually and add the taxonomy in the backend(without caldera form) and when I published the post I can see that it is tagged with the taxonomy.
    My question is even though the select a taxonomy field is assigned, is there any further step to be followed in order for the taxonomy to be “tagged” or “assigned” to the post?

    https://www.ads-software.com/plugins/caldera-forms/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Josh Pollock

    (@shelob9)

    Our custom fields add-on, at this time, does not create taxonomy associations. I would recommend using the Run Action processor to fire an action, grab the taxonomy field from there and pass it to wp_set_object_terms()

    See:
    https://calderawp.com/doc/custom-processing-of-caldera-forms-submissions/
    https://codex.www.ads-software.com/Function_Reference/wp_set_object_terms
    https://calderawp.com/downloads/caldera-forms-run-action/

    I’m looking to implement the same here. So I can use the following hook to populate an array with the data from the form;

    add_action( ‘caldera_forms_submit_complete’, ‘slug_process_form’, 55 );
    function slug_process_form( $form ) {

    //put form field data into an array $data
    $data= array();
    foreach( $form[ ‘fields’ ] as $field_id => $field){
    $data[ $field[‘slug’] ] = Caldera_Forms::get_field_data( $field_id, $form );
    }

    //get embedded post ID.
    $embeded_post_id = absint( $_POST[ ‘_cf_cr_pst’ ] );

    /** DO SOMETHING WITH $data here **/
    }

    Followed by something like;

    wp_set_object_terms( $embeded_post_id, $data[5], ‘taxonomy’ );

    Where ‘taxonomy’ is some defined taxonomy, and $data[5] assumes some sort of field order. And I’m just using ‘caldera_forms_submit_complete’ as the Run Action (no args).

    However, I think I’m missing something here :-/

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Taxonomy assigned’ is closed to new replies.