um_user
Description
This function can be used to get a user's specific field data or meta value. This can be user profile data or user permissions.
Usage
<?php echo um_user( $data ); ?>
Parameters
$data
(string) (required) The field or data you want to retrieve for user.
$attrs
(string) (optional) Additional attribute for profile data that may need extra configuration.
Returns
Returns the user data requested If found. A user must be previously set using um_fetch_user() to properly retrieve user data.
Examples
The example below can retrieve the user's display name
<?php $display_name = um_user('display_name'); echo $display_name; // prints the user's display name ?>
The example below can retrieve the user's community role
<?php echo um_user('role_name'); // example: Member or Admin ?>
You have to use functions um_fetch_user() and um_reset_user() if you want to use the function um_user() in the PHP loop.
/** * Users loop, example */ $user_ids = array( 123, 456, 789 ); foreach ( $users_ids as $users_id ) { um_fetch_user( $user_id ); // Some custom code $display_name = um_user('display_name'); echo $display_name; // Some custom code } um_reset_user();