Updater user with multiple roles

admin2025-06-03  5

I have searched the net for explanations, but I only find my own question without any real answer. Like this one: Adding multiple user roles dynamically

I need to dynamically assign more than one role to some users. However, it seems that WordPress core is built for only one role per user. I have used Members plugin to define more roles. And they seem to reside in wp_options, along with the 'native' ones. But it seems impossible to update the user->role with an array.

Any suggestions?

I have searched the net for explanations, but I only find my own question without any real answer. Like this one: Adding multiple user roles dynamically

I need to dynamically assign more than one role to some users. However, it seems that WordPress core is built for only one role per user. I have used Members plugin to define more roles. And they seem to reside in wp_options, along with the 'native' ones. But it seems impossible to update the user->role with an array.

Any suggestions?

Share Improve this question asked Feb 19, 2019 at 16:04 halhal 351 gold badge1 silver badge9 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

Roles are assigned one per user. That's default for WordPress. Instead of using roles, I recommend using capabilities to keep track of different types of users. You can assign multiple capabilities per user and set some default capabilities for the role.

See: add_cap() and remove_cap()

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748889387a314566.html

最新回复(0)