WPBP / WordPress-Plugin-Boilerplate-Powered

Wordpress Plugin Boilerplate but Powered with examples and a generator!
https://wpbp.github.io/
GNU General Public License v3.0
791 stars 114 forks source link

custom plugin options/settings page only visible to custom role's dashboard #201

Closed steveadamsfixedit closed 2 years ago

steveadamsfixedit commented 2 years ago

I'm building a plugin based on the boilerplate that contains analytics data on virtual events attended by logged in users. The entire system is restricted to a hierarchy of users from the top down as follows: Admins, Moderators, Presenters, Attendees. I've granted Moderators access to the WP dashboard where I want to display a 'settings/options' page where they can see the activity analytics data of the attendees for only the events that are under their moderation control. Admins should be able to see all event analytics for all events tied to all moderators. Currently, I've constructed this page in my custom_plugin/admin/partials/custom_plugin-events.php file and it is displaying all the activity at an administrator level. Furthermore, I've constructed the custom post type for the events and the custom roles with access. The moderator can see the custom post type in their dashboard. My question is threefold:

1) How do I make the event analytics page at the wp-admin/admin.php?page=custom_plugin-events url visible in the moderator's dashboard? 2) I'm presently using some conditional logic in this admin/partial page that basically says if user_can=admin show this data and if user_can=moderator show this other data. Is that the correct and recommended approach? 3) If I'm requiring all these users to be logged in and applied to one custom role or another...is the custom_plugin/admin directory the correct place to implement this? or would it be better in custom_plugin/public?

Mte90 commented 2 years ago

Well this depends if you want to give access to the backend or not. If you want to let to access to backend I don't know where you added the link or how you are showing it, anyway in this line https://github.com/WPBP/WordPress-Plugin-Boilerplate-Powered/blob/master/plugin-name/backend/Settings_Page.php#L62 there is the wp function that set the link based on capabilities of the user in this case manage_options that means only admin basically.

About 2 and 3 you are right. Backend is for the wordpress backend but the admin/public folder doesn't exist in this boilerplate.

Mte90 commented 2 years ago

I am closing this as you opened the same request in 4 different boilerplates, this is not right as behaviour to developers that do this for free in their projects.