How to create a shortcode to output the user ID of any profile page.

Many plugins provide a shortcode to output data for a specific user and they require the user ID.
If you want to add one of these shortcodes in a new tab of the users' profile pages, you'll also need a shortcode to output the user ID for each profile page.
For that, you can add the following code to a snippet using the Code Snippet plugin, or add it to your theme functions.php and finally use the shortcode [profile_owner_ID] to output the user ID of the profile owner on any profile.
// Creating shortcode:  [profile_owner_ID]

function display_profile_owner_ID () {
    $user = uwp_get_displayed_user();
    return isset($user->ID) ? absint($user->ID) : '';
}

add_shortcode('profile_owner_ID', 'display_profile_owner_ID');
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.