Overview

The Gigya module provides a set of hooks that enables you to dynamically change variable values that are passed to Drupal and/or override Gigya module functionality.

Every Gigya API call that is invoked by the module goes through “drupal_alter” functions before being sent to Gigya's servers. To interact with or extend the Gigya module, simply implement corresponding hooks in your own module code. For each hook, the prefix 'hook' in the name of the function is a placeholder for the name of your module. For example, if you want to implement a hook to modify the global conf object, and your module is called 'my_module', implement a function called my_module_gigya_global_conf_alter($gigya_js_settings);

Sample module: For an example of how to implement these hooks in your own code, download our sample "Gigya Client" module, which includes an example of using the gigya_raas_create_user_alter hook. Review the code and use the module as a reference for your own hook implementations.

Available Hooks

The following table describes the hooks available in the Gigya module.

All these hooks are included in the file {modules install dir}/gigya/gigya.api.php.

Alter Gigya global configuration parameters, e.g. the list of social network and other identity providers, or the interface language. See all available parameters in the Global Conf documentation. Note that these parameters are not handled as standard Drupal JavaScript settings, but instead are included as an object in the HTML head section of the page.

hook_notify_login_user_info_alter

&$gigya_user_info

This hook is called before calling Gigya's notifyLogin API method. The parameter &$gigya_user_info passed to the hook function is the user info that will be sent to Gigya. You can use and alter the following fields before they are sent: nickname, photoURL, thumbnailURL, firstName, lastName, gender, age, email.

hook_gigya_create_user_alter

&$form_state

$bio

Alter parameters for a new user when it is created via Gigya login. The parameters that are passed to the alter function are:

$form_state - the form that gets sent to Drupal as the new user registration form

This hook is run before the Gigya tokens are returned. Other modules can implement this hook to changes values provide by Gigya or to add values.Use $replacements as a key->value set for altering the available $tokens. For more information click here.

This hook lets other modules modify the user array before it is sent to the user save function when a user is created via RaaS. The first parameter is the array that would be sent to the user_save function. The second one is the parameter is the info passed from Gigya on the getAccountInfo response data.

hook_gigya_raas_update_user_alter

&$edit

$user

$gigya_info

This hook is called after the user logs in to the site using RaaS. Use it to alter user data before it is sent to the server.

The $edit parameter is in place of the $new_user_array sent to the user save function.

$gigya_account the gigya account array as retread from gigya getAccountInfo.

hook_gigya_login_register_response_alter

&$commands

$ctx

$drupal_user

$gigya_user

This hook is used to differentiate between a returning user (login event) and a new user (registration event). An example of using such a hook is to redirect new users to one page ('Thank you!') and returning users to another ('Welcome Back!').

This hook is called before adding the socialize.showShareUI configuration parameters to the Javascript settings. A list of available parameters can be found at the method's API page. Note this is used for “action sharing”, defined by Drupal’s rules mechanism.

$js_block_name is the name of the block as it was created in the admin section.

hook_gigya_gm_notifications_alter

&$notification_settings

Alter the notifications plugin parameters. The following example would prevent the notification popup from closing automatically: $notification_settings['closeTimeout'] = 0;. See relevant keys. $notification_settings is the array that would passed to the notification plugin.

Code Sample

The following is a PHP code sample that illustrate a basic use of hooks to alter parameters sent to the Game mechanics plugin before they are loaded.