Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function custom_wpf_forms_apply_tags( $apply_tags, $user_id, $contact_id, $form_id ) {
- // Check if this is from Gravity Forms
- if ( ! function_exists( 'rgpost' ) || ! isset( $_POST['gform_submit'] ) ) {
- return $apply_tags;
- }
- // Get the value from field ID 10.
- $tag_name = rgpost( 'input_10' );
- $tag_id = wpf_get_tag_id( $tag_name );
- if ( ! $tag_id ) {
- $tag_id = wp_fusion()->crm->add_tag( $tag_name );
- if ( is_wp_error( $tag_id ) ) {
- wpf_log( 'error', 0, 'Error adding tag ' . $tag_name . ': ' . $tag_id->get_error_message() );
- return $apply_tags;
- }
- // Update the local cache of tags.
- wp_fusion()->crm->sync_tags();
- }
- $apply_tags[] = $tag_id;
- return $apply_tags;
- }
- add_filter( 'wpf_forms_apply_tags', 'custom_wpf_forms_apply_tags', 10, 4 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement