bp_core_get_userid( string $username = '' )
Return the user ID based on a user’s user_login.
Description
Parameters
- $username
-
(Optional) user_login to check.
Default value: ''
Return
(int|null) The ID of the matched user on success, null on failure.
Source
File: bp-members/bp-members-functions.php
function bp_core_get_userid( $username = '' ) { if ( empty( $username ) ) { return false; } $user = get_user_by( 'login', $username ); /** * Filters the ID of a user, based on user_login. * * @since BuddyPress 1.0.1 * * @param int|null $value ID of the user or null. * @param string $username User login to check. */ return apply_filters( 'bp_core_get_userid', ! empty( $user->ID ) ? $user->ID : NULL, $username ); }
Changelog
Version | Description |
---|---|
BuddyPress 1.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.