FAQ Q214: Can Planyo integrate with the login system used on my website?

The planyo modules/plugins for the following CMSes: joomla, drupal, wordpress, modx have a possibility to use the built-in logging system of these CMSes. This can be optionally switched on in module/plugin settings.

In order to switch on the login integration you must do the following:
When the CMS login is enabled, the reservation form will always display known fields in personal details. You may also use special tags in your templates to take advantage of the login feature: $(is_user_logged_in) and $(logged_in_reservation_list_url). The first one can be used to conditionally output a different content in case a user is logged in and the second one is a URL of a special page where a logged in client can see and manage all their reservations made in the past. If you want to add a link to this page outside of the planyo templates, you can simply link to the page which contains the planyo plugin with the ?mode=reservation_list URL parameter.

With the login enabled, you can also use another login-related feature, in resource properties you can select the option Only users who are logged in can make reservations. Doing this will force users to first log into your website and then make reservations.

Instructions for login integration when not using a dedicated planyo plugin

If you're using the PHP integration method, and not one of the dedicated CMS plugins, you still can add an integration with your website's login system using a few lines of PHP code. In order to do this, after pasting the PHP code for the integration, following the instructions in Site settings / Integrate with my website / Advanced / PHP based integration, you'll need to modify the presented code by adding a few lines. Anywhere BEFORE the planyo-plugin-impl.php file is included (the last line in the code below) enter the following code (in green):

global $planyo_login_info;
$user_id = ""; // fill with user id or login name
$user_email = ""; // fill with user's email
$user_first_name = ""; // fill with user's first name
$user_last_name = ""; // fill with user's last name
$integration_code = ""; // fill this with the login integration code from the advanced integration settings in the planyo backend
$planyo_login_info = array('first_name'=>$user_first_name, 'last_name'=>$user_last_name, 'email'=>$user_email, 'login_cs'=>sha1($user_email . $integration_code));

You will need to fill out the $user_xxx variables with the values coming from the currently logged-in user.

If you're using a different server-side scripting language than PHP (e.g. Ruby, ASP.NET, Java etc.):

In such case, use the HTML copy&paste integration method which doesn't require PHP support. Then, before the pasted HTML code from planyo, you'll need to output the following HTML code using your server-side language:
window.planyo_login = {first_name: "VAL1", last_name: "VAL2", email: "VAL3", login_cs: "VAL4"};

In the javascript array created above you'll of course need to replace values VAL1 .. VAL4 with the currently logged in user's information as follows:
VAL1: user's first name
VAL2: user's last name
VAL3: user's email address
VAL4: is the result of the SHA1 hash function where the input string is c0ncatenation of user's email address and INTEGRATION-CODE (without any delimiting character). INTEGRATION-CODE is the login integration code from the advanced integration settings in the planyo backend.
Security warning: NEVER output the plain integration code directly in the javascript. You need to calculate the SHA1 hash on the SERVER-SIDE. Otherwise the solution will not be secure.
Domande frequenti