最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Load Custom Field to User Profile as per User Role using Ajax

programmeradmin0浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 0

You 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/

发布评论

评论列表(0)

  1. 暂无评论