$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>Creating Custom user type just like custom post|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Creating Custom user type just like custom post

matteradmin8PV0评论

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.

Share Improve this question edited Feb 19, 2019 at 14:17 Nidheesh Chandran asked Oct 30, 2013 at 13:47 Nidheesh ChandranNidheesh Chandran 32 bronze badges 1
  • Please improve your question, see How to Ask. Plugin recommendations are off topic, see On Topic. – Nicolai Grossherr Commented Oct 30, 2013 at 13:52
Add a comment  | 

1 Answer 1

Reset to default 0

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.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far