Get Store Vendor Role
-
Hello,
On my registration page, I have the user select role functionality.
When a user registers as Server Developer my custom functions add him ‘vendor_store’ role.
That means the user has x2 roles.I want to show at the store page his role by image.
For example https://prnt.sc/tqu7ch (I know that’s not the store its just an example)The code I use is this
$current_user = new WP_User(wp_get_current_user()->id); $user_roles = $current_user->roles; foreach ($user_roles as $role) { if ($role == 'administrator' ){ echo '<img src="/wp-content/user_ranks/userimg_administrator.png">'; } if ($role == 'client_developer' ){ echo '<img src="/wp-content/user_ranks/userimg_client_developer.png">'; } if ($role == 'server_developer' ){ echo '<img src="/wp-content/user_ranks/userimg_server_developer.png">'; } if ($role == 'website_developer' ){ echo '<img src="/wp-content/user_ranks/userimg_web_developer.png">'; } if ($role == 'clan_leader' ){ echo '<img src="/wp-content/user_ranks/userimg_clanleader.png">'; } if ($role == 'journalist' ){ echo '<img src="/wp-content/user_ranks/userimg_journalist.png">'; } if ($role == 'regular' ){ echo '<img src="/wp-content/user_ranks/userimg_regular_member.png">'; } if ($role == 'premium' ){ echo '<img src="/wp-content/user_ranks/userimg_premium.png">'; } }
As you can see I use
$current_user = new WP_User(wp_get_current_user()->id);
for store-manager which is fine.
If I do the same on Store Page it will show the role image from the user who is visiting the page and not the role image of the store owner.Could you please help me?
Thank you in advance!
- The topic ‘Get Store Vendor Role’ is closed to new replies.