PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.14
Booktics – Appointment Booking Calendar for Service Businesses v1.0.14
1.0.29 1.0.28 1.0.27 1.0.26 1.0.25 1.0.24 1.0.23 1.0.22 1.0.21 1.0.20 1.0.19 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.2 1.0.3 All 31 releases
booktics / core / appointment / appointment-hooks.php

appointment-hooks.php in Booktics – Appointment Booking Calendar for Service Businesses 1.0.14, at core/appointment/appointment-hooks.php

49 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Booktics\Appointment;
4
5 use Booktics\Contracts\Hookable_Service_Contract;
6
7 class Appointment_Hooks implements Hookable_Service_Contract {
8
9 /**
10 * Register the appointment hooks.
11 *
12 * @return void
13 */
14 public function register() {
15 add_filter( 'booktics_appointment_args', array(
16 $this,
17 'booktics_appointment_args'
18 ) );
19 }
20
21 /**
22 * Filter appointment arguments based on the current user's role.
23 *
24 * @param array $args The appointment arguments.
25 *
26 * @return array The filtered appointment arguments.
27 */
28 public function booktics_appointment_args( $args ) {
29 $current_user = wp_get_current_user();
30 $roles = $current_user->roles;
31
32 if ( in_array( 'administrator', $roles, true ) ) {
33 return $args;
34 }
35
36 if ( in_array( 'booktics_team_member', $roles, true ) ) {
37 if ( ! isset( $args['meta_query'] ) ) {
38 $args['meta_query'] = [];
39 }
40 $args['meta_query'][] = array(
41 'key' => 'team_member_id',
42 'value' => $current_user->ID,
43 'compare' => '=',
44 );
45 }
46
47 return $args;
48 }
49 }