Uname: Linux webm012.cluster130.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
Software: Apache
PHP version: 8.0.30 [ PHP INFO ] PHP os: Linux
Server Ip: 145.239.37.162
Your Ip: 216.73.216.190
User: dreampi (1009562) | Group: users (100)
Safe Mode: OFF
Disable Function:
_dyuweyrj4,_dyuweyrj4r,dl

name : UserRoles.php
<?php

namespace AmeliaBooking\Infrastructure\WP\UserRoles;

/**
 * Class UserRoles
 *
 * @package AmeliaBooking\Infrastructure\WP
 */
class UserRoles
{
    /**
     * @param $roles
     */
    public static function init($roles)
    {
        /** @var array $roles */
        foreach ($roles as $role) {
            if (!wp_roles()->is_role($role['name'])) {
                add_role($role['name'], $role['label'], $role['capabilities']);
            }
        }
    }

    /**
     * Return the current user amelia role
     *
     * @param $wpUser
     * @return string|null
     */
    public static function getUserAmeliaRole($wpUser)
    {
        if (in_array('administrator', $wpUser->roles, true) || is_super_admin($wpUser->ID)) {
            return 'admin';
        }

        if (in_array('wpamelia-manager', $wpUser->roles, true)) {
            return 'manager';
        }

        if (in_array('wpamelia-provider', $wpUser->roles, true)) {
            return 'provider';
        }

        if (in_array('wpamelia-customer', $wpUser->roles, true)) {
            return 'customer';
        }

        return null;
    }
}
© 2026 GrazzMean-Shell