Give permission to admin to see user’s page

Instead of using $user_id = get_current_user_id(), you want to get the ID of the author by doing something like

$author = get_user_by( 'slug', get_query_var( 'author_name' ) );

or

if ( $author= get_query_var( 'author' ) ) { $author = get_user_by( 'id', $author_id ); }

And then use like

 $user_id = $author->ID;

Source: https://wordpress.stackexchange.com/a/35251/47406

tech