I am currently developing a plugin for online doctor booking for patients. Doctor and Patient both need to register on the site. The users (doctors and patients) can be managed from the Users section.
Here the requirement is, super admin (wp-admin) can also add any doctor or any patient against any doctor. The custom fields need to be loaded according to the selected user role i.e. doctor (name, address, specialist, qualification, etc.) or patient (symptoms, the start date of symptom, etc.)
I have used below codes to add fields to user section:
add_action( 'user_new_form', 'dbt_load_usertype_fields' );
add_action( 'show_user_profile', 'dbt_load_usertype_fields' );
add_action( 'edit_user_profile', 'dbt_load_usertype_fields' );
but I need fields according to the role of the user. I also tried using WP Ajax to achieve this, but could not succeeded.
May you please help me, how will I achieve this?
I am currently developing a plugin for online doctor booking for patients. Doctor and Patient both need to register on the site. The users (doctors and patients) can be managed from the Users section.
Here the requirement is, super admin (wp-admin) can also add any doctor or any patient against any doctor. The custom fields need to be loaded according to the selected user role i.e. doctor (name, address, specialist, qualification, etc.) or patient (symptoms, the start date of symptom, etc.)
I have used below codes to add fields to user section:
add_action( 'user_new_form', 'dbt_load_usertype_fields' );
add_action( 'show_user_profile', 'dbt_load_usertype_fields' );
add_action( 'edit_user_profile', 'dbt_load_usertype_fields' );
but I need fields according to the role of the user. I also tried using WP Ajax to achieve this, but could not succeeded.
May you please help me, how will I achieve this?
Share Improve this question edited Dec 13, 2020 at 15:12 fuxia♦ 107k38 gold badges255 silver badges459 bronze badges asked Dec 13, 2020 at 5:52 Arnab ChatterjeeArnab Chatterjee 552 silver badges7 bronze badges1 Answer
Reset to default 0You probably don't need to use ajax, you just need to check for user role and screen and output your required fields / metaboxes .
How to check if a user is in a specific role?
https://developer.wordpress/reference/functions/get_current_screen/