Problem: I would like to automatically assign a specific taxonomy term to posts created by a CRED Form.
Solution: Add the following code to your child theme's functions.php file:
add_action('cred_save_data', 'auto_cred_term_action',10,2); function auto_cred_term_action($post_id, $form_data) { // news posts if ($form_data['id']==123) { $tag = array( 149 ); // Taxonomy term ID $taxonomy="category"; // Taxonomy name wp_set_post_terms( $post_id, $tag, $taxonomy ); } }
Replace 123 with the numeric ID of the CRED form, then remove the taxonomy cred_field shortcode from the CRED form builder.
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
Dieses Thema enthält 3 Antworten, hat 2 Stimmen.
Zuletzt aktualisiert von vor 6 Jahren, 8 Monaten.
Assistiert von: Christian Cox.