How to create custom user types (User Role) just like the custom post types.
For example:
User Role 1: Having a normal profile field. User Role 2: Having 3 extra fields in the profile.
2 different set of users with different user_meta fields.
How to create custom user types (User Role) just like the custom post types.
For example:
User Role 1: Having a normal profile field. User Role 2: Having 3 extra fields in the profile.
2 different set of users with different user_meta fields.
Well, Roles are in many ways custom user types and you can add meta fields specific to roles. For example...
function is_my_user_role($id = null) {
global $profileuser;
if (empty($profile) && !empty($id)) $profileuser = get_user_to_edit($id);
return (in_array('myrole',$profileuser->roles)) ? true : false;
}
function my_user_fields($profileuser) {
if (!is_my_user_role()) return false;
// HTML for the fields
}
add_action('show_user_profile', 'my_user_fields');
add_action('edit_user_profile', 'my_user_fields');
And essentially the same check when you go to save the data.