bbp_get_displayed_user_field( string $field = '', string $filter = 'display' )
Return a sanitized user field value
Description Description
This function relies on the $filter parameter to decide how to sanitize the field value that it finds. Since it uses the WP_User object’s magic __get() method, it can also be used to get user_meta values.
See also See also
- WP_User::__get(): for more on how the value is retrieved
- sanitize_user_field(): for more on how the value is sanitized
Parameters Parameters
- $field
-
(Optional) Field to get
Default value: ''
- $filter
-
(Optional) How to filter the field value (null|raw|db|display|edit)
Default value: 'display'
Return Return
(string|bool) Value of the field if it exists, else false
Source Source
File: includes/users/template.php
function bbp_get_displayed_user_field( $field = '', $filter = 'display' ) { // Get the displayed user $user = bbpress()->displayed_user; // Juggle the user filter property because we don't want to muck up how // other code might interact with this object. $old_filter = $user->filter; $user->filter = $filter; // Get the field value from the WP_User object. We don't need to perform // an isset() because the WP_User::__get() does it for us. $value = $user->$field; // Put back the user filter property that was previously juggled above. $user->filter = $old_filter; // Filter & return return apply_filters( 'bbp_get_displayed_user_field', $value, $field, $filter ); }
Changelog Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |