admin管理员组

文章数量:1125063

I am using Careerfy Theme for wordpress which is basically a job board and has Candidate and Employer User roles set for new registrations. I want registered users to be able to switch between these roles via link in the menu. Please can someone help me if that will be possible and how can it be achieved. Thank you.

I am using Careerfy Theme for wordpress which is basically a job board and has Candidate and Employer User roles set for new registrations. I want registered users to be able to switch between these roles via link in the menu. Please can someone help me if that will be possible and how can it be achieved. Thank you.

Share Improve this question asked Feb 11, 2024 at 7:22 Job Hunt CommunityJob Hunt Community 1 2
  • You'll have to ask the Careerfy Theme development or support - this is a third-party theme and has it's own structure and nuance. – Tony Djukic Commented Feb 14, 2024 at 16:04
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Bot Commented Feb 14, 2024 at 16:04
Add a comment  | 

1 Answer 1

Reset to default 0

Lets say you are logged in as "Candidate" and if you want to switch to "Employer" , you should then create a new user record with employer role and keep the candidate user_id in employer usermeta table as "switch_user_id"

Suppose that candidate user_id is 4 and if you switch it will first check if "switch_user_id" exist or not, if not then it will create a new user with employer role. For this this newly created employer you should also store "switch_user_id".

So now if you try to switch then get the switch_user_id , logout the current user and login to the other user id.

wp_users

id |         user_email                | username ... 
4  |      [email protected]          | candidate 
5  | [email protected] | candidate_gmail_com

wp_usermeta

user_id |     meta_key   | meta_value
   4    | switch_user_id |   5
   5    | switch_user_id |   4

本文标签: How to allow users in wordpress to switch between two assigned roles eg Candidate amp Employer