• Sander

    (@sander-falise)


    I’m looking for a way to add custom role support to your plugin, I can see a bunch of apply_filters hooks in your code that would allow me to add limited viewing capabilities to a custom role but I get stuck on the add_menu_page() call that only allows 2 capabilities to use the plugin at all; view_all_aryo_activity_log and edit_pages. My custom role does NOT allow edit_pages and when I give my role the cap view_all_aryo_activity_log there is no way to use any of the hooks for aal_init_roles and aal_init_caps since the view_all cap allows all to be seen. I suggest a simple addition to the create_admin_menu function;

    $menu_capability = apply_filters( ‘aal_view_cap’, current_user_can( ‘view_all_aryo_activity_log’ ) ? ‘view_all_aryo_activity_log’ : ‘edit_pages’ );

    This way I can create my own cap to allow a user to see the page at all, and use the other hooks to decide what modules and roles are allowed to be seen.

    Regards & compliments, Sander.

Viewing 1 replies (of 1 total)
  • Thread Starter Sander

    (@sander-falise)

    I adding the above line to my localhost version of the plugin and that seems to work as expected. There is however one more issue I’d like to see changed;

    Method _get_allow_caps() in class-aal-activity-log-list-table.php on line 39

    // TODO: Find better way to Multisite compatibility.
    if ( ( is_multisite() && is_super_admin() ) || current_user_can( ‘view_all_aryo_activity_log’ ) )
    {
    $allow_caps = $this->_caps[‘administrator’];
    }

    Adding is_multisite() ensures that is_super_admin checks only work on a multisite environment, my custom role is allowed to delete_users (in some cases) and for some reason is_super_admin() checks for that exact cap when NOT in multisite mode …

Viewing 1 replies (of 1 total)
  • The topic ‘Custom rules for custom roles’ is closed to new replies.