Advertisement
verygoodplugins

Untitled

Mar 25th, 2021
704
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.67 KB | None | 0 0
  1.     /**
  2.      * Gets user ID from contact ID
  3.      *
  4.      * @access public
  5.      * @return int User ID
  6.      */
  7.  
  8.     public function get_user_id( $contact_id ) {
  9.  
  10.         do_action( 'wpf_get_user_id_start', $contact_id );
  11.  
  12.         $user_id = apply_filters( 'wpf_user_id', false, $contact_id );
  13.  
  14.         if ( false !== $user_id ) {
  15.             return $user_id; // Allow bypassing the database query
  16.         }
  17.  
  18.         $users = get_users(
  19.             array(
  20.                 'meta_key'   => wp_fusion()->crm->slug . '_contact_id',
  21.                 'meta_value' => $contact_id,
  22.                 'fields'     => array( 'ID' ),
  23.             )
  24.         );
  25.  
  26.         if ( ! empty( $users ) ) {
  27.             return apply_filters( 'wpf_user_id', $users[0]->ID, $contact_id );
  28.         } else {
  29.             return false;
  30.         }
  31.  
  32.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement