Appointments Role Access

Hello:

How can I set the permissions so a service provider ONLY see's their scheduled appointments? I went to Advanced => Appointments Role Access => Appointments page => and provided the user level access, however, different sites can still see others appointments. When they log into their admin, and go to Appointments => Appointments, they should only see their designated appointments (and not be able to filter through other service providers).

  • Adam Czajczyk

    Hello Quincy,

    I hope you're well today and thank you for your question!

    The question applies to the Appointments+ plugin on Multisite install, is that correct?

    I'm not sure if I understand it correctly though: is it that the admins of other sub-sites can see appointments booked on other sub-sites? Or is it about service providers within some particular, selected sub-site?

    The default "permissions" for admins would be like this:

    - super-admin can see everything everywhere
    - admin of multiple sub-sites can see appointments on these multiple sub-sites but that should be a separate set of appointments on each subsite (so in site A dashboard there are only appointments booked on site A and in site B dashboard there should only be appointments booked on site B etc.)
    - admin of a single sub-site should see only appointments within the dashboard of that sub-site and it should be only booking from that sub-site

    Can you please explain what's happening on your site in more details?

    Best regards,
    Adam

  • Quincy

    Hi Adam,

    Yes, Appointments+ plugin. I’m on a multisite install, but this doesn’t necessarily apply to a multisite.

    I’m trying to avoid going the route of setting up multiple subsites per service provider, since we have a call center service that will schedule appointments for all service providers. The service provider in this case are doctors offices, so the appointments cannot be shared access across the ‘service providers.’ They can only see their respective appointments. Our call center should have access to schedule appointments for all offices (as an admin), but the individual offices should only have access to their own appointments.

    The setup works great with this plugin if we provide each office a different ‘Page’ to schedule appointments, however, when they log into Wordpress’ Admin, they see each offices appointments. I found a custom script in a thread similar to this, but that is only to pre-filter the service provider to that logged-in user. In this case, they cannot have that access. It would be ideal if it could filter to that office and hide the filter, so they could not change it.

    Hopefully, this provides more detail.

    Thanks,
    Quincy

  • Dimitris

    Hey there Quincy,

    hope you're doing good and don't mind chiming in! :slight_smile:

    Service providers don't have any special role and/or capabilities, actually they can be from subscribers to administrators, while only the latest have the ability to manage Appointments+ settings.

    What I would propose to you, would be to create a multisite installation and set each separate service provider as this site's administrator.

    For better administration by you, you can use a plugin like "User Switching"
    https://wordpress.org/plugins/user-switching/

    Warm regards,
    Dimitris

  • Quincy

    Hi Demitris,

    I don't mind at all. The problem with creating separate subsites is that our call center would then need to manage multiple schedules in multiple locations opposed to one single location. If this was 2-3 offices, it wouldn't pose an issue, but if it's 20-30-some offices, it's a bit of an issue.

    Is there no possible way to eliminate the dropdown filter and only display to what user is logged in? I found this on another one of your forums:

    global $current_user;

    if ( ! current_user_can('administrator') && appointments_is_worker( $current_user->ID ) ) {
    $worker_id = $current_user->ID;
    }

    But it only pre-filters to that user id. This would work if the dropdown was eliminated. Does this make sense?

  • Dimitris

    Hey there Quincy,

    I just tested the solution of Panos from this thread
    https://premium.wpmudev.org/forums/topic/have-provider-view-only-their-appointments-only-in-appointments-admin-page
    and it seems to be working! :slight_smile:

    You just have to insert the following snippet in
    /wp-content/plugins/appointments/admin/pages/class-admin-appointments-page.php around line 207

    global $current_user;
    if ( ! current_user_can('administrator') && appointments_is_worker( $current_user->ID ) ) {
    	$worker_id = $current_user->ID;
    }


    Please keep in mind that current user should be a service provider and not having an administrator role.

    In order to hide the dropdown list of service providers, even though it can't fetch data related to them, you can use the following snippet like a MU plugin.
    Simply access your server and create a new folder (if it doesn't exist already) like /wp-content/mu-plugins/. In there create a .php file so in the end you will have /wp-content/mu-plugins/admin-styles.php. This file should contains

    <?php
    add_action('admin_head', 'my_custom_admin_css');
    function my_custom_admin_css() {
      echo '<style>#app_provider_id { display: none; }</style>';
    }

    Warm regards,
    Dimitris

  • Predrag Dubajic

    Hi Quincy,

    Unfortunately there's no way for this customization to be done differently and it would require the code to be re-added after the update.

    You could apply some CSS to your non super admin users to hide those button, you can do that by adding this as mu-plugin in your network:

    <?php
    function hide_export_buttons() {
    if( !is_super_admin() ) {
    ?>
    
    	<style type="text/css">
    		#app-export-type,
    		#app-export-all {
    		    display: none;
    		}
    	</style>
    
    <?php }
    }
    add_action( 'admin_head', 'hide_export_buttons' );

    Let us know if that does the trick :slight_smile:

    Best regards,
    Predrag

  • Adam Czajczyk

    Hello Quincy!

    The update shows up as an available update in both "WPMU DEV -> Plugins" and "Dashboard -> Updates" sections of your site.

    If you just copy the plugin to another folder that will still be the same plugin and you won't be able to install a "second copy" of it as there'll be a lot of conflicts of classes/functions names. The solution provided by Dimitris would have to be re-applied upon update. The one provided by Predrag will not however be overwritten by updates.

    Will this script hide it for the admin as well? The admin will still need to do a data dump.

    The code provided by Predrag should hide that from everyone except super admins only. If you wish it to hide button from everyone except both super-admin and site admin, try this code instead please:

    <?php
    function hide_export_buttons() {
    if ((!is_super_admin()) AND (!current_user_can('administrator'))) {
    ?>
    
    	<style type="text/css">
    		#app-export-type,
    		#app-export-all {
    		    display: none;
    		}
    	</style>
    
    <?php }
    }
    add_action( 'admin_head', 'hide_export_buttons' );

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.