bbp_get_user_nicename( int $user_id, array $args = array() )
Return a users nicename to the screen
Description
Parameters
- $user_id
-
(Required) User ID whose nicename to get
- $args
-
(Optional) before|after|user_id|force
Default value: array()
Return
(string) User nicename, maybe wrapped in before/after strings
Source
File: bp-forums/users/template.php
function bbp_get_user_nicename( $user_id = 0, $args = array() ) { // Bail if no user ID passed $user_id = bbp_get_user_id( $user_id ); if ( empty( $user_id ) ) return false; // Parse default arguments $r = bbp_parse_args( $args, array( 'user_id' => $user_id, 'before' => '', 'after' => '', 'force' => '' ), 'get_user_nicename' ); // Get the user data and nicename if ( empty( $r['force'] ) ) { $user = get_userdata( $user_id ); $nicename = $user->user_nicename; // Force the nicename to something else } else { $nicename = (string) $r['force']; } // Maybe wrap the nicename $retval = !empty( $nicename ) ? ( $r['before'] . $nicename . $r['after'] ) : ''; // Filter and return return (string) apply_filters( 'bbp_get_user_nicename', $retval, $user_id, $r ); }
Changelog
Version | Description |
---|---|
bbPress (r4671) | 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.