Let site editors (or other roles) add/edit opening times
Per default, only site admins can change plugin settings, including opening times. If you want other WordPress roles, such as editors, to be able to change the plugin’s settings, paste the following PHP code at the bottom of your functions.php file:
add_filter('mbhi_capability', function($capability) { return 'edit_posts'; }); add_filter( 'option_page_capability_mabel-business-hours-indicator-pro', 'bhi_setting_capability' ); function bhi_setting_capability( $capability ) { return 'edit_posts'; }
Note: in the code above, we’re returning edit_posts
as the minimum capability a user needs in order to edit the plugin’s settings. You can find all possible capabilities here on WordPress.org.
Note 2: The code above is for the premium version of the plugin. If you’re using the free version, replacemabel-business-hours-indicator-pro
with business-hours-indicator
.
If you’d like to create a completely new role which will only be able to edit hours, paste this code at the bottom of your functions.php file. The role in this example is called “Business Hours Manager”.
add_filter('mbhi_capability', function($capability) { if(current_user_can('manage_options')) return 'manage_options'; // To allow admins to also edit the hours. return 'manage_business_hours'; }); remove_role('business_hours_manager'); add_role('business_hours_manager','Business Hours Manager', array( 'read' => true, 'edit_posts' => true, 'manage_business_hours' => true, )); add_filter('option_page_capability_mabel-business-hours-indicator-pro','set_bhi_options_capability'); function set_bhi_options_capability($capa){ if(current_user_can('manage_options')) return $capa; return 'manage_business_hours'; }
Note: The code above is for the premium version of the plugin. If you’re using the free version, replacemabel-business-hours-indicator-pro
with business-hours-indicator
.