um_fetch_user
Description
This function sets a user and allows you to retrieve any information for the retrieved user
Usage
<?php um_fetch_user( $user_id ); ?>
Parameters
$user_id
(numeric) (required) A user ID is required. This is the user’s ID that you wish to set/retrieve.
Returns
Sets a specific user, prepares profile data and user permissions, and makes them accessible.
Examples
The example below will set user ID 5 prior to retrieving his profile information.
<?php um_fetch_user(5); echo um_user('display_name'); // returns the display name of user ID 5 ?>
In the following example, you can fetch the profile of a logged-in user dynamically.
<?php if( is_user_logged_in() ){ um_fetch_user( get_current_user_id() ); echo um_user('display_name'); // returns the display name of logged-in user } ?>
The following example can be used on the profile page to get information about the profile owner.
<?php $user_id = um_profile_id(); if( $user_id ){ um_fetch_user( $user_id ); echo um_user('display_name'); // returns the display name of the profile owner } ?>
Warning: This function changes the global User object. Use the function um_reset_user() to avoid conflicts at the end of your custom code.