Load Custom Field to User Profile as per User Role using Ajax
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?