Okay
  Public Ticket #3122218
WordPress Users vs Amelia Users
Closed

Comments

  • Nathan Wilson started the conversation

    All of my website users are required to be signed into WordPress before they can access Amelia's services to make or manage bookings.

    I use Ultimate Memberships Pro to manage membership levels.

    Membership level A can act as an Amelia customer.

    Membership level B can act as an Amelia customer and an Amelia employee.

    Users have the ability to switch between Membership level A and B.

    How do I make sure that every new WordPress user automatically gets signed in to Amelia so they don't have to create an Amelia account and sign in a second time? 

    I can manually edit the role cabilities to include the ones attributed to Amelia using the "User role editor" plugin.

    I just need the appropriate accounts created in Amelia and the requirement to sign in a second time removed.

    Can you please help?

  •  1,127
    Uroš replied

    Hello Nathan,

    Thank you for reaching out to us.

    Unfortunately, there is currently no such option with Amelia's built-in features. You can suggest that feature on the following link: https://features.wpamelia.com/ 

    We carefully follow suggestions from our customers and the more vote the feature gets, the more priority we put on implementing that feature in one of the future updates.

    Please let us know if you have any other questions.


    Kind Regards, 

    Uros Jovanovic
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Rick replied

    I need the same as this and I already added it to the features request.

    If my members are already logged in and make a booking, and I set Amelia to create a new account when a booking is made, is there no way that Amelia can recognise that they’re already logged in when they visit the front end customer panel page?

  •  1,127
    Uroš replied

    Hello Rick,

    When a user with the "Amelia Customer" role is logged into WordPress, they will automatically be logged into the customer panel.

    Please let us know if you have any other questions.


    Kind Regards, 

    Uros Jovanovic
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Nathan Wilson replied

    Hi Uros,

    My users are not logged into the Amelia customer panel if they are logged into WordPress.

    After they login to WordPress and then navigate to the customer panel, they are still required to login there.

    My members all have the Amelia Customer role assigned.

    Can you please confirm how my members can automatically be logged into the customer panel?

  •  1,127
    Uroš replied

    Hello Nathan,

    Thank you for clearing that up.

    Please provide me a temporary WP-admin (administrator) user for your site where this happens, so we could log in and take a look ‘from the inside’ as that’s the most efficient way to see and resolve the issue. 

    We do not interfere with any data or anything else except for the plugin (in case that’s a production version of the site), and of course, we do not provide login data to third parties. 

    You can write credentials here just check PRIVATE Reply so nobody can see them except us.


    Kind Regards, 

    Uros Jovanovic
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Rick replied

    Got it and works perfectly for me. I was checking it with my admin account which doesn’t have the Amelia customer role.

    Great support 👏👏

  • Nathan Wilson replied

    Hi Uros,

    Thanks for the quick replies here.

    Appologies, I have gotten two issues mixed up at one here...

    I can confirm that user that appear under the Amelia customer or employee list that have the appropriate permissions assigned (in my case, I do this using the user role editor).

    However, all new members are created outside of Amelia. How do I ensure that all new members (created through Ultimate Membership Pro) are populated into the Amelia customer list? 

    Can I hook into the UMP code to run some php to do this?

  •  1,127
    Uroš replied

    Hello Rick,

    Glad to hear that.

    Hello Nathan, 

    You could try the following code for that purpose:

    function createCustomers()
    {    $args  = array(
            'role'    => 'wpamelia-customer',
        );
        $users = get_users($args);
        $container = require AMELIA_PATH . '/src/Infrastructure/ContainerConfig/container.php';
        /** @var CustomerApplicationService $customerAS */    $customerAS = $container->get('application.user.customer.service');
        foreach ($users as $user) {
            $userMetaData = get_user_meta($user->ID);
            $userArr      =
                [   'status'     => 'visible',
                    'type'       => 'customer',
                    'firstName'  => !empty($userMetaData['first_name'][0]) ? $userMetaData['first_name'][0] : $user->data->user_login,
                    'lastName'   => !empty($userMetaData['last_name'][0]) ? $userMetaData['last_name'][0] : $user->data->user_login,
                    'email'      => $user->data->user_email,
                    'externalId' => $user->ID,
                ];
            $customerAS->createCustomer($userArr, true);
        }
    }

    Please let us know if it works or not.

    Looking forward to your reply.


    Kind Regards, 

    Uros Jovanovic
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Rick replied

    Hi Uros,

    Does this just go in functions.php ?

    function createCustomers()
    {    $args  = array(
            'role'    => 'wpamelia-customer',
        );
        $users = get_users($args);
        $container = require AMELIA_PATH . '/src/Infrastructure/ContainerConfig/container.php';
        /** @var CustomerApplicationService $customerAS */    $customerAS = $container->get('application.user.customer.service');
        foreach ($users as $user) {
            $userMetaData = get_user_meta($user->ID);
            $userArr      =
                [   'status'     => 'visible',
                    'type'       => 'customer',
                    'firstName'  => !empty($userMetaData['first_name'][0]) ? $userMetaData['first_name'][0] : $user->data->user_login,
                    'lastName'   => !empty($userMetaData['last_name'][0]) ? $userMetaData['last_name'][0] : $user->data->user_login,
                    'email'      => $user->data->user_email,
                    'externalId' => $user->ID,
                ];
            $customerAS->createCustomer($userArr, true);
        }
    }
  •  1,127
    Uroš replied

    Hello Rick,

    That is right, it should work fine if you add that code in the functions.php file.

    Please let us know if you have any other questions.


    Kind Regards, 

    Uros Jovanovic
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Nathan Wilson replied

    Hi Uros,


    Sorry! I thought I replied to this months ago and wondered why I didn't get a reply!

    That code worked just as expected, thanks heaps for that.

    Do you mind sending through the code to add a Employee/provider?


  •  1,127
    Uroš replied

    Hello Nathan,

    Thank you for reaching back out to us.

    The following code creates an Employee in Amelia from the wp user with the "Amelia Employee" role:

    function createProviders()
    {   $args  = array(
            'role'    => 'wpamelia-provider',
        );
        $users = get_users($args);
        $container = require AMELIA_PATH . '/src/Infrastructure/ContainerConfig/container.php';
        /** @var SettingsService $settingsService */    $settingsService = $container->get('domain.settings.service');
        /** @var LocationRepository $locationRepository */    $locationRepository = $container->get('domain.locations.repository');    /** @var ProviderApplicationService $providerAS */    $providerAS = $container->get('application.user.provider.service');
        $schedule    = $settingsService->getCategorySettings('weekSchedule');    $weekDayList = getWorkHours($schedule);
        foreach ($users as $user) {        $userMetaData = get_user_meta($user->ID);
            $locations = $locationRepository->getFiltered([], 1);
            $userArr =            [                'status'      => 'visible',                'type'        => 'provider',                'password'    => $user->data->user_pass,                'firstName'  => !empty($userMetaData['first_name'][0]) ? $userMetaData['first_name'][0] : $user->data->user_login,                'lastName'   => !empty($userMetaData['last_name'][0]) ? $userMetaData['last_name'][0] : $user->data->user_login,                'email'       => $user->data->user_email,                'externalId'  => $user->ID,                'weekDayList' => $weekDayList,                'sendEmployeePanelAccessEmail' => true,                'locationId'  => $locations && $locations->length() && $locations->getItem(0) ? $locations->getItem(0)->getId()->getValue() : ''            ];
            $providerAS->createProvider($userArr, true);    }
    }

    Please let me know if it works or not.

    Looking forward to your reply.


    Kind Regards, 

    Uros Jovanovic
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Nathan Wilson replied

    Hi Uros,


    I'm getting a 500 error on line $weekDayList = getWorkHours($schedule);

    Error (simplified removing the full stack trace): Call to undefined function getWorkHours() in /var/www/vhosts/aijp.com.au/httpdocs/wp-content/themes/AIJP/functions.php

    Copied code:

    function createProviders() {   

    $args  = array(
            'role'    => 'wpamelia-provider',
        );
        $users = get_users($args);
        $container = require AMELIA_PATH . '/src/Infrastructure/ContainerConfig/container.php';
        /** @var SettingsService $settingsService */    
      $settingsService = $container->get('domain.settings.service');
        /** @var LocationRepository $locationRepository */    
      $locationRepository = $container->get('domain.locations.repository');    
      /** @var ProviderApplicationService $providerAS */    
      $providerAS = $container->get('application.user.provider.service');
        $schedule    = $settingsService->getCategorySettings('weekSchedule');    
      $weekDayList = getWorkHours($schedule);
        foreach ($users as $user) {
    $userMetaData = get_user_meta($user->ID);
            $locations = $locationRepository->getFiltered([], 1);
            $userArr =
    [ 'status'      => 'visible',
    'type'        => 'provider',
    'password'    => $user->data->user_pass,
    'firstName'  => !empty($userMetaData['first_name'][0]) ? $userMetaData['first_name'][0] : $user->data->user_login,
    'lastName'   => !empty($userMetaData['last_name'][0]) ? $userMetaData['last_name'][0] : $user->data->user_login,
    'email'       => $user->data->user_email,
    'externalId'  => $user->ID,
    'weekDayList' => $weekDayList,
    'sendEmployeePanelAccessEmail' => true,
    'locationId'  => $locations && $locations->length() && $locations->getItem(0) ? $locations->getItem(0)->getId()->getValue() : ''            
    ];
            $providerAS->createProvider($userArr, true);    
    }
    }


  •  1,127
    Uroš replied

    Hello Nathan,

    Please add the following code before the one I sent you first:

    function getWorkHours($schedule)
    {    $weekDayList = [];
        foreach ((array)$schedule as $index => $weekDay) {
            $timeoutList = [];
            foreach ($weekDay['breaks'] as $break) {
                array_push($timeoutList, ['id'=>null, 'startTime'=>$break['time'][0].':00', 'endTime'=>$break['time'][1].':00']);
            }
            $periodList = [];
            if ($weekDay['time'][0] !== null && $weekDay['time'][1] !== null) {
                if (!(array_key_exists('periods', $weekDay))) {
                    $period = [
                        'id' => null,
                        'startTime' => $weekDay['time'][0] . ':00',
                        'endTime'  => $weekDay['time'][1] . ':00',
                        'serviceIds' => [],
                        'locationId' => null,
                        'periodServiceList' => [],
                        'savedPeriodServiceList' => []
                    ];
                    array_push($periodList, $period);
                } else {
                    foreach ($weekDay['periods'] as $period) {
                        $periodItem = [
                            'id' => null,
                            'startTime' => $period['time'][0] . ':00',
                            'endTime'  => $period['time'][1] . ':00',
                            'serviceIds' => [],
                            'locationId' => null,
                            'periodServiceList' => [],
                            'savedPeriodServiceList' => []
                        ];
                        array_push($periodList, $periodItem);
                    }
                }
                $weekDayItem =[
                    'dayIndex' => $index + 1,
                    'id' => null,
                    'startTime' => $weekDay['time'][0] . ':00',
                    'endTime'  => $weekDay['time'][1] . ':00',
                    'periodList' => $periodList,
                    'timeoutList' => $timeoutList
                ];
                array_push($weekDayList, $weekDayItem);
            }
        }    return $weekDayList;
    }

    Please let me know if it works or not.

    Looking forward to your reply.


    Kind Regards, 

    Uros Jovanovic
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Nathan Wilson replied

    Thanks Uros, that worked perfectly.

    Quite a few of my users will soon become customers and providers at the same time.

    I'm planning on writing a small php script to update the "type" column in the "wp_amelia_users" table when the user clicks a button to switch from a customer to a provider.

    Is this the best way to complete this task?

    Or do you have a better alternative?

  • Nathan Wilson replied

    Ok, tried this. Worked perfectly.

    However, when the user was viewing as a custsomer, they were unable to be booked as a provider.

    Any way around this?

  •  1,127
    Uroš replied

    Hello Nathan,

    Firstly, I would like to sincerely apologize for the delayed response as we have been experiencing an unusually high number of tickets. I am sorry that it has taken longer than usual to respond to your concern and your patience is highly appreciated.

    Thank you for the update.

    Can you please elaborate on this question?

    However, when the user was viewing as a custsomer, they were unable to be booked as a provider.

    Looking forward to your reply.


    Kind Regards, 

    Uros Jovanovic
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Nathan Wilson replied

    No problems, thanks for the continued assistance.

    When a user has the role type set as customer in wp_Amelia_users, they do not show as a bookable provider.


    Therefore if one of my providers wants to check what booking they have and their role type is set to customer to allow viewing of the customer front end panel, during this time they cannot be booked by other customers as they don't show as a provider.


    Is it possible to have the role type in wp_amelia_users set as an array to allow multiple types?

  •  1,127
    Uroš replied

    Hello Nathan,

    Thank you for clearing that up.

    Unfortunately, it is not possible to have an Amelia employee also have the Amelia customer role as it causes a conflict between roles and permissions for each role.

    Hope this helps you.

    Please let me know if you have any other questions.


    Kind Regards, 

    Uros Jovanovic
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Nick Law replied

    Hi Uros,

    Just looking for a solution to a similar problem I'm having and came across this code.

    Am I right in thinking that this code will automatically create a customer in Amelia rather than merely creating a Wordpress user whose role is 'Amelia Customer'?

    Thanks,

    Nick

  •  1,127
    Uroš replied

    Hello Nick,

    The code that I provided Nathan with works only with BuddyBoss and does not work in relation to employees in Amelia also being customers.

    Please let me know if you have any other questions by creating a new ticket.


    Kind Regards, 

    Uros Jovanovic
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Nick Law replied

    Can I ask why a customer can't use a password they create during the Wordpress registration process (especially if they are assigned an 'Amelia Customer') to access the front-end panel unless they book a service or package first?  Is there no way around being able give someone access to the panel and allow them to book a service through there?

  •  1,127
    Uroš replied

    Hello Nick,

    Thank you for reaching back out to us.

    In order to allow existing WordPress users to log both into WordPress (or WooCommerce, or some membership plugin) and Amelia using the same credentials, customers and employees in Amelia need to have "Amelia Customer" or "Amelia Employee" user role assigned to them. 

    If there's a created WordPress user, but they don't yet have anything purchased through Amelia, you need to enable "Automatically create Amelia Customer user" in Amelia Settings/Roles/Customer, and then - after they log into their WordPress user, once they land on Amelia's booking page, their details will already be populated, and once they purchase the appointment, they'll be added to Amelia/Customers; linked to the WordPress user, and they will be able to visit the Amelia Customer Panel without logging in (since they're already logged in as a WordPress user).

    If you already created a user with "Amelia Customer" but they haven't purchased anything with Amelia yet, that user won't be linked to any customers you have in Amelia, so before they are able to log into Amelia's Customer Panel, they either need to book an appointment while they're logged into WordPress, WooCommerce, or a membership plugin, or you need to create a customer by going into Amelia/Customers/Add Customer. When you create a customer, link that customer to the WordPress user, and that's it. After that, they will be able to log in with the same password that's used for logging into WordPress.

    Please take a look at our video about this: https://youtu.be/nm7f7RDSYow

    Please note: If you change the password of the employee, or the customer through WordPress, the same password will apply to Amelia's Panels, but if you change the password through the Customer or the Employee Panel in Amelia, that password will not be applied to the WordPress user role. This is because Amelia doesn't require a WordPress user to be created in order to grant access to the panels - that is optional, and Amelia can't modify the password for WordPress users.


    Kind Regards, 

    Uros Jovanovic
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables