tombenner/wp-mvc

expose admin pages to selected non-admins

dbleier opened this issue · 6 comments

I have been using wp-mvc for some time now and it is fantastic. I currently have some admin pages which we would now like to expose to our support staff without giving them full admin privileges.

Is there any way to expose an admin page to a selected non-admin role? And if so, how to do it?

thanks.

figured it out.
in bootstrap.php added:

MvcConfiguration::append(array(
	'AdminPages' => array(
           'admin_page_1' => array('capability' => 'access_page_1'),
           'admin_page_2' => array('capability' => 'access_page_2'),
	)
));

And then using User Role Editor added the access_page_1 and access_page_2 capabilities and assigned them to the support role. 😄

Great!

There's a full working demo here: https://github.com/cyberscribe/tapoetry

thanks!

What about index page??? Suppose I have a admin_book_controller with index() function. I want that index function to be accessible to super admin & contributor, but also have delete() function which should be accessible only to admin. How do we achieve that??
I tried by giving separate cabability to index => access_index & for delete => access_delete, but using that, in URL I need to entry admin.php?page=mvc_book-index also.
Any solution on that?

Using MvcConfiguration::set('admin_controller_capabilities' = array('admin_book_controller' => 'your_permission_name_here')) will let you set permissions for the entire admin controller to be visible/accessible to that permission level. There is not currently any way to set permissions for each method of that admin controller independently. However, in the method for the controller class you are free to check user permissions and give the standard WordPress 'You do not have sufficient permissions to access this page' message. If you would like to propose a pull request with options to both disable access and visibility on a method-by-method basis using MvcConfiguration, we'd be happy to consider that. :)

Thanks @cyberscribe, will get back to you soon with that in mind! :)