Support » Plugin: Caldera Forms Run Action » Set Taxonomy for New Custom Post

  • I am attempting to use a run action to set a newly created posts terms upon submit. This was starting to be addressed on another thread but not resolved.
    Starting a unique thread here. similar to an unresolved issue over here:

    My action does not seem to be inserting the terms. Below is my settings and Action.
    I am using the plugin: Caldera Forms, Caldera Custom Fields, & Run Action

    Run Action:

      Run On Submission: Insert
      Position: Post-Process
      Type: Action
      Action/Filter: cf_set_features_taxonomy

    Theme Functions Action
    //action: caldera forms Set Taxonomy
    add_action( ‘cf_set_features_taxonomy’, ‘cf_set_slug_process_form’,55);
    function cf_set_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’ ] );
    wp_set_object_terms( $embeded_post_id, $data[ ‘taxonomy_term_slug’ ], ‘taxonomy_name’, true );
    //If I set the $embeded_post_id = 720, and the $data=array(20,40) then the post id 720’s taxonomy is assigned 20 & 40. If I update one or the other neither is updated.

Viewing 1 replies (of 1 total)
  • Thread Starter jzager


    I created a new plugin, and now this is partially working. I am setting the action to the next post id manually, and the terms are being assigned upon form submission and post creation.

    Now I have set the $embeded_post_id back to = absint( $_POST[ ‘_cf_cr_pst’ ] ) and it will not work.

Viewing 1 replies (of 1 total)
  • The topic ‘Set Taxonomy for New Custom Post’ is closed to new replies.