Assign a Content Template with CRED depending on Taxonomy

This CRED submit_complete hook allows you to assign a certain Content Template to a new Post (or edited) depending on the Taxonomy term assigned to the Post.

You can extend the if/elseif with more terms and taxonomies if you like
The Content Template is hardcoded, but could be extended to a $variable, it just does not make much sense

function my_success_action($post_id, $form_data) {
    // if a specific form
    if ($form_data['id']==ID){ //replace ID with actual CRED ID
            $ct_one = ID;//replace ID with the Content template ID
            $ct_two = ID;//replace ID with the Content template ID
 
            if (has_term( 'your-term', 'your-taxonomy', $post_id )){
                update_post_meta($post_id, '_views_template', $ct_one);     
            }
            elseif (has_term( 'your-second-term', 'your-taxonomy', $post_id )) {
                update_post_meta($post_id, '_views_template', $ct_two);  
            }
                 
    }
}
add_action('cred_submit_complete', 'my_success_action',10,2);

Support Thread Example

Let us know if this snippet is not working for you:

This snippet doesn’t work
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments