Make WordPress Core

Opened 6 years ago

Last modified 6 years ago

#45709 new enhancement

Suggestion for User Roles

Reported by: lotharthesavior's profile lotharthesavior Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Role/Capability Keywords:
Focuses: administration, multisite, performance Cc:

Description

Hello,

User Roles on WordPress works through a serialized object in a record at the wp_options table in the database. I understand that this might be considered enough. Although, I have a suggestion for improvement:

I had a problem while working with multisites: I imported one website, and it happens that multisites depends on the name of the option at the wp_options table. Because I only updated the name of the tables, I couldn't see my user roles because that part is in the name of the option. After importing/updating it I could see.

I believe that it would be more maintainable if we had a separate table wp_roles instead. I would like to hear some comments on that.If enough people agrees or have some positive thoughts on that, I might prototype a plugin for the community to try it out.

Thanks!
Savio Resende

Change History (4)

#1 @dingo_bastard
6 years ago

Kinda like the sound of that but not sure if this will happen due to any BC.

Would we need wp_capabilities table, or would this all be in one table? How would multiple roles work for one user? Would we need an extra table to have one to many relationships (if one user needs to have multiple roles)?

I'm definitely interested if this has any future :)

#2 @knutsp
6 years ago

Hello @lotharthesavior

Welcome to Track and thanks for this suggestion.

Since the {$table_prefix}roles option lives in a table with the same $table_prefix the prefix is obviously redundant. If I remember correctly, it has been suggested to remove it quite a few times here on Trac.

However, such a change will not solve anything when it comes to end users, like performance. A new roles table, like the current option, will only hold the very few roles that exists on a site.

The main problem with the current capabilities system is probably that it's inefficient to query for users with a certain capability without using the deprecated user_level option. The whole structure could need a well thought out overhaul some day.

Your suggestion will certainly make life easier for those who manually export/import or copy db tables, and for the authors of migration plugins, but such will have to be weighed against other priorities, the amount of work involved and the risk of breaks in backwards compatibility.

What would be a really useful change is to join a table from users that has all the capabilities, so that all user having, like edit_posts, can be queried by a singe SELECT.

IMHO.

This ticket was mentioned in Slack in #core-restapi by desrosj. View the logs.


6 years ago

#4 @desrosj
6 years ago

  • Focuses rest-api removed
  • Severity changed from minor to normal
  • Version 5.0.1 deleted
Note: See TracTickets for help on using tickets.