Advertisement
verygoodplugins

Untitled

May 2nd, 2020
609
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  1. function my_update_custom_post( $user_id, $user_tags ) {
  2.  
  3.     $args = array(
  4.         'post_type' => 'dating_profile',
  5.         'author'    => $user_id,
  6.         'fields'    => 'ids',
  7.     );
  8.  
  9.     $profiles = get_posts( $args );
  10.  
  11.     if ( ! empty( $profiles ) ) {
  12.  
  13.         $profile_id = $profiles[0];
  14.  
  15.         if ( in_array( 'Type One', $user_tags ) ) {
  16.  
  17.             wp_set_post_terms( $profile_id, 'Type One Term', 'profiles_taxonomy', true );
  18.  
  19.         } elseif ( in_array( 'Type Two', $user_tags ) ) {
  20.  
  21.             wp_set_post_terms( $profile_id, 'Type Two Term', 'profiles_taxonomy', true );
  22.  
  23.         }
  24.  
  25.     }
  26.  
  27. }
  28.  
  29. add_action( 'wpf_tags_modified', 'my_update_custom_post', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement