bp_core_get_userid_from_nicename

Return the user ID based on a user's user_nicename.

Description

(int|null) bp_core_get_userid_from_nicename( (string) $user_nicename = '' ); 

Returns (int|null)

The ID of the matched user on success, null on failure.

Parameters (1)

0. $user_nicename — Optional. (string) => ''
User_nicename to check.

Usage

  1. if ( !function_exists( 'bp_core_get_userid_from_nicename' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-members/bp-members-functions.php'; 
  3.  
  4. // user_nicename to check. 
  5. $user_nicename = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_core_get_userid_from_nicename($user_nicename); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-members/bp-members-functions.php  
  1. function bp_core_get_userid_from_nicename( $user_nicename = '' ) { 
  2. if ( empty( $user_nicename ) ) { 
  3. return false; 
  4.  
  5. $user = get_user_by( 'slug', $user_nicename ); 
  6.  
  7. /** 
  8. * Filters the user ID based on user_nicename. 
  9. * @since 1.2.3 
  10. * @param int|null $value ID of the user or null. 
  11. * @param string $user_nicename User nicename to check. 
  12. */ 
  13. return apply_filters( 'bp_core_get_userid_from_nicename', ! empty( $user->ID ) ? $user->ID : NULL, $user_nicename );