Advertisement
verygoodplugins

Untitled

Apr 24th, 2025
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1. function custom_wpf_forms_apply_tags( $apply_tags, $user_id, $contact_id, $form_id ) {
  2.  
  3.     // Check if this is from Gravity Forms
  4.     if ( ! function_exists( 'rgpost' ) || ! isset( $_POST['gform_submit'] ) ) {
  5.         return $apply_tags;
  6.     }
  7.  
  8.     // Get the value from field ID 10.
  9.     $tag_name = rgpost( 'input_10' );
  10.  
  11.     $tag_id = wpf_get_tag_id( $tag_name );
  12.  
  13.     if ( ! $tag_id ) {
  14.         $tag_id = wp_fusion()->crm->add_tag( $tag_name );
  15.  
  16.         if ( is_wp_error( $tag_id ) ) {
  17.             wpf_log( 'error', 0, 'Error adding tag ' . $tag_name . ': ' . $tag_id->get_error_message() );
  18.             return $apply_tags;
  19.         }
  20.  
  21.         // Update the local cache of tags.
  22.         wp_fusion()->crm->sync_tags();
  23.  
  24.     }
  25.  
  26.     $apply_tags[] = $tag_id;
  27.  
  28.     return $apply_tags;
  29. }
  30.  
  31. add_filter( 'wpf_forms_apply_tags', 'custom_wpf_forms_apply_tags', 10, 4 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement