0

I'm writing a code for author.php . I access this by: http://example.com/author/{user_nicename} Imagine there are some users (Including 1 Admin, 4 or 5 editors, and so on ...) Now when users click on above URL, They see their own Information. I want to give permission to Admin and Editors to see the other arbitrary users Information. How can i do that? This is a part of my code in author.php :

<?php
get_header();
$user_id = get_current_user_id();
global $wpdb;
$result = $wpdb->get_results(" SELECT display_name 
                               FROM wp_introduction 
                               INNER JOIN wp_users 
                               ON costumer_id = ID 
                               WHERE $introducer_id = $user_id" );

var_dump($result);
get_sidebar();
get_footer();

?>

1 Answer 1

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.