Create Topic

WP Tavern Forums Create Topic

Create New Topic

Justin Tadlock

It’s best to handle this sort of thing by capability rather than role anyway. Even if you wanted to do a pretty interface for regular folks, you could add something like an rda_admin_access capability for the roles that are allowed. You’d just code that behind the scenes. It’d actually be pretty simple:

The UI would be a list of all [editable] roles with checkboxes next to them. These checked roles would have access.

On save/update settings, you grab all roles. For the selected roles, add the custom capability. For unselected roles, check if they have the capability and remove it if they do.

On plugin activation, auto-add the capability to roles like Administrator, Editor, Author, and Contributor or just the Administrator.

Doing it this way would make it so much better because it’d be easy for people who do use plugins like Members to create custom roles and have it play nicely with this plugin. They can even manage access from within Members if they were already on the role-editing screen. I need to write more tutorials in this area. Now, I’ll stop thinking out loud and go build something.






Newsletter

Subscribe Via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.