Actions
nsl-add-providers
This action helps you adding new providers to the plugin.
nsl-providers-loaded
This action runs after every provider has been loaded and ordered correctly.NextendSocialLogin::$providers contains all available providers.NextendSocialLogin::$enabledProviders contains only the enabled providers.
Connect Flow actions/filters
{{provider-id}}_login_action_before
This action run first after the user clicked the social login button. It has only one parameter, the current provider. It extends from the NextendSocialProvider class.
{{provider-id}}_login_redirect_url
A filter to override the login redirect url. It has two parameters:
- Fixed redirect URL, if set
- current provider
It returns the new redirect URL.
Example:
add_filter('facebook_login_redirect_url', function($redirectUrl, $provider){ return $redirectUrl;}, 10, 2);
{{provider-id}}_register_redirect_url
It’s the same as the {{provider-id}}_login_redirect_url. It has the same two parameters, but it happens upon registration:
- Fixed redirect URL, if set
- current provider
nsl_register_new_user
This happens when a new user is registered with any of the providers. Parameteres:
$user_id- provider instance
nsl_{{provider-id}}_register_new_user
This action runs when the user registers with the given provider. Parameters:
$user_id- provider instance
nsl_{{provider-id}}_auto_link_allowed
This filter can prevent linking the user accounts automatically for a user when it returns false.
Parameters:
- $isAutoLinkAllowed
- current provider instance
$user_id
nsl_{{provider-id}}_is_login_allowed
This filter can prevent the login for the user when it returns false.
Parameters:
- $isAutoLoginAllowed
- current provider instance
$user_id
nsl_login
This action runs when a user logs in with any of the providers.
Parameters:
$user_id- provider instance
nsl_{{provider-id}}_login
This action runs when a user logs in with the given provider.
Parameters:
$user_id- provider instance
- access_token
nsl_autologin_priority
Our auto-login after social registration may block third-party code hooked to the “user_register” action. Use this filter to delay our auto-login.
Parameters:
- $autoLoginPriority – Higher numbers correspond with later execution. We suggest not to decrease the value below the default auto-login priority.
nsl_pre_register_new_user
This action runs before the new user is registered.
Parameters:
NextendSocialUser class instance
nsl_is_register_allowed
This filter defines whether the user registration is allowed or not.
Parameters:
- boolean
- provider instance
Available since: 3.0.4
nsl_{{provider-id}}_link_user
This action runs when a user link the account to a given provider, registration with the given provider also triggers this hook.
Parameters:
- $user_id
- provider id
nsl_unlink_user
This action runs when a user unlinks a social media account from a certain provider.
Parameters:
- $user_id
- provider id
- unlinked social media id
Available since: 3.0.28 / “unlinked social media id” parameter added in 3.1.6
nsl_registration_user_data
This filter can be used for overriding certain userdata before the registration or preventing the registration.
Parameters:
- $userData – associative array – username and email
- $provider – provider instance, that can be used to retrieve some data of current user.
- $error – error object, that can be used for preventing the registration.
nsl_disabled_register_redirect_url
This filter can be used for overriding the URL where the user will be redirected, if the registration is disabled.
Parameters:
- $redirectUrl – string – the url of the page
Available since: 3.0.25
nsl_disabled_register_error_message
This filter can be used for overriding the message that is displayed when the registration is disabled with Nextend Social Login.
Parameters:
- $errorMessage – string – the error message
- $provider – provider instance
Starting from version 3.0.28 passing “false” in the return value can be used for disabling the default error message!
Available since: 3.0.25
nsl_{{provider-id}}_auth_url_args
This filter can be used for overriding authorization URL arguments of each provider.
Parameters:
- $args – associative array – contains the current authorization URL arguments.
Available since: 3.0.26
nsl_match_social_account_to_user_id
This filter can be used for overriding the User ID that the social account should be linked to.
Parameters:
- $user_id – the ID of the WordPress account where the social account should be linked to
- social user instance
- current provider instance
Available since: 3.0.26
nsl_disabled_login_redirect_url
This filter can be used for overriding the URL where the user will be redirected, if the login is disabled.
Return value:
- string – the URL where the user should be redirected
Available since: 3.0.27
nsl_disabled_login_error_message
This filter can be used for overriding the message that is displayed when the login is disabled with Nextend Social Login.
Return value:
- string – the error message
Available since: 3.0.27
nsl_already_linked_error_message
This filter can be used for overriding the message that is displayed when a person tries to connect with a social media account, that’s email address is registered on the site and has another social media account from the same kind already linked.
Return value:
- string – the error message
Available since: 3.0.30
nsl_bypass_cache_url
This filter can be used for adding custom GET parameters to the redirect URL, when the “Bypass cache on redirect” setting is enabled. By default the name of the parameter is “nsl_bypass_cache” and its value is a unique hash.
Parameters:
- $url – string – the URL where the user should be redirected to
Return value:
- string – the URL where the user should be redirected to ( To attempt bypassing the cache, at least one GET parameter should be added into the URL! )
Example:
add_filter('nsl_bypass_cache_url', function ($url) { return add_query_arg(array("abc" => "123"), $url); });
Available since: 3.1.4
nsl_connect_button_custom_attributes
You can use this filter to add custom attributes to the connect button.
Example:
add_filter('nsl_connect_button_custom_attributes', function ($attr, $provider) {
$attr['attrbute'] = "value";
return $attr;
}, 10, 2);
Available since: 3.1.5
nsl_register_roles
You can use this filter to override the role that the user should be registered with.
Parameters:
- $roles – array – contains the role or roles that the user should be registered with
- $provider – provider instance, that can be used to retrieve some data of current user.
Available since: 3.1.14
nsl_register_flow_page
You can use this filter to override the page ID selected in the “Page for register flow” setting.
Parameters:
- $pageID – integer– the ID of the page, where we should handle the registration flow, instead of the page that was selected.
Available since: 3.1.23
nsl_{{provider-id}}_delete_login_persistent_data
Runs when the plugin deletes the temporary session data of one sign-in (login or linking, popup mode, register flow form token, access token), so an extension can delete what it stored for the same sign-in.
Parameters:
- $provider – the current provider instance
Available since: 3.1.27
nsl_{{provider-id}}_delete_token_persistent_data
Runs when the plugin throws away the stored result of the authentication (access token and state, or the claimed ID for OpenID providers), so the next attempt starts at the provider again and the visitor can pick another account.
Parameters:
- the current provider instance
Available since: 3.1.27
Provider exclusive actions/filters:
Google:
nsl_google_one_tap_should_display
You can use this filter to decide whether the Google One Tap prompt should be displayed on the current page.
Parameters:
- $shouldDisplay – boolean – whether Nextend Social Login would display the prompt.
- $provider – the Google provider instance.
- $isLoginPage – boolean – true on the /wp-login.php page.
Example, hiding the prompt on the WooCommerce checkout page:
add_filter('nsl_google_one_tap_should_display', function ($shouldDisplay) {
if (function_exists('is_checkout') && is_checkout()) {
return false;
}
return $shouldDisplay;
});
Available since: 3.1.27
nsl_google_one_tap_needs_access_token
One Tap signs the visitor in with Google’s ID token, which can’t access Google’s APIs. When this filter returns true, the One Tap sign-in continues through Google’s authorization page, so Nextend Social Login gets the access token too.
Parameters:
- $needsAccessToken – boolean – true when the Sync data fields or the storing of the access token need the access token for this sign-in.
- $provider – the Google provider instance.
- $sub – string – the Google account ID of the visitor.
Don’t return false while Sync data fields are enabled, because syncing those fields needs the access token, so the sign-in would fail.
Available since: 3.1.27
nsl_google_one_tap_itp_support
In Safari, Firefox and Chrome on iOS, Google shows the One Tap prompt to every logged-out visitor, because it can’t check there whether the visitor is signed in to Google. Return false with this filter to turn the prompt off in these browsers.
Parameters:
- $itpSupport – boolean – true by default.
- $provider – the Google provider instance.
Example:
add_filter('nsl_google_one_tap_itp_support', '__return_false');
Available since: 3.1.27