Hello everybody!
I'm trying to edit Members Directory plugin so it shows user role along with website, name and bio.
Code:
Problem:
For some reason this code works only if the user is administrator. So, if user is administrator, then this code is creating line: "Rank: administrator". But, if user have any other rank, then $role_administrator is an empty string so I get: "Rank: ".
At first, I thought that the code placement is wrong, but I've tried to print $user_idd instead of $role_container[0], and I'm getting expected output(different id printed on different profiles).
Also weird - While desperately searching for solution, I've even tried to get user level(which is deprecated) instead of user role - and I'm getting the same problem - user level displays only for administrator :S
Any ideas ?
*Note - Source says that this is a free software under the GNU licence, so I can add the code of the whole plugin here if that helps.
Thank you.
I'm trying to edit Members Directory plugin so it shows user role along with website, name and bio.
Code:
Code:
Get user id:
$user_idd = $user_details->ID;
Get role of that user:
$user_current = new WP_User( $user_idd );
$role_container = $user_current->roles;
Display user role:
$content .= '<strong>' . __('Rank') . '</strong>: ' . $role_container[0] . '<br />';
Problem:
For some reason this code works only if the user is administrator. So, if user is administrator, then this code is creating line: "Rank: administrator". But, if user have any other rank, then $role_administrator is an empty string so I get: "Rank: ".
At first, I thought that the code placement is wrong, but I've tried to print $user_idd instead of $role_container[0], and I'm getting expected output(different id printed on different profiles).
Also weird - While desperately searching for solution, I've even tried to get user level(which is deprecated) instead of user role - and I'm getting the same problem - user level displays only for administrator :S
Any ideas ?
*Note - Source says that this is a free software under the GNU licence, so I can add the code of the whole plugin here if that helps.
Thank you.