728x90
7
1
I need to somehow check someones role with only their id. I have found the current_user_can()
check. But this only works for people that are logged in. How would I check for this if that user isn't the current user? I am using a phone order system but that uses the the admin/specific acount to order for other people.
Thank you
21
You can't get user role directly. First, you have to get the user_meta_data, and it will return an Object that will contain user roles.
Code:
$user_meta=get_userdata($user_id);
$user_roles=$user_meta->roles; //array of roles the user is part of.
'WEB > WP(WordPress)' 카테고리의 다른 글
Code To Integrate WordPress Media Uploader In Plugin or Theme (0) | 2018.04.10 |
---|---|
How to insert data using wpdb (0) | 2018.04.09 |
Using WPDB in standalone script? (0) | 2018.04.08 |
[function] get_post (0) | 2018.04.07 |
What action should I hook into when adding roles and capabilities? (0) | 2018.04.06 |