WooCommerce Social Login Developer Hook Reference

Overview ↑ Back to top

WooCommerce Social Login includes actions and filters to customize the way your social buttons are displayed.

This document is provided as a courtesy for developers and designers. Please note that we do not support or offer customization services as part of our support policy. Any sample code provided is simply for reference.

Filter Reference ↑ Back to top

wc_social_login_find_by_email_allowed_user_roles
Filter array of roles that should allow non-logged in account linking. See example.
Return: array
wc_social_login_profile_image
Filter the user’s profile image URL.
Return: string
wc_social_login_providers
Filter the list of providers to load.
Return: array
wc_social_login_auth_path
Filter the authentication base path. Default: ‘auth’
Return: string
wc_social_login_available_providers
Filter the available providers.
Return: array
wc_social_login_provider_default_form_fields
Filter default provider settings form fields; passes in provider ID (ie ‘facebook’) as a parameter.
Return: array
wc_social_login_provider_available
Filter whether the provider is available or not.
Return: bool
"wc_social_login_{$provider_id}_new_user_data"
Filter data for user created by social login. Passes in \WC_Social_Login_Provider_Profile profile instance as a parameter.
Return: array
wc_social_login_provider_title
Filter social login provider’s title. Passes in provider ID (ie ‘facebook’) as a parameter.
Return: string
wc_social_login_provider_client_id
Filter the provider’s app client ID. Passes in provider ID (ie ‘facebook’) as a parameter.
Return: string
wc_social_login_provider_client_secret
Filter the provider’s app client secret. Passes in provider ID (ie ‘facebook’) as a parameter.
Return: string
wc_social_login_provider_login_button_text
Filter social login provider’s login button text. Passes in provider ID (ie ‘facebook’) as a parameter.
Return: string
wc_social_login_provider_link_button_text
Filter social login provider’s link button text. Passes in provider ID (ie ‘facebook’) as a parameter.
Return: string
wc_social_login_provider_color
Filter social login provider’s color. Passes in provider ID (ie ‘facebook’) as a parameter.
Return: string
wc_social_login_{$provider_id}_profile
Filter provider’s profile. Allows for normalization of array of user data from provider.
Return: array
wc_social_login_billing_profile_mapping
Filter billing fields.
Return: array
woocommerce_social_login_settings
Filter social login settings.
Return: array
wc_social_login_display
Filter where social login buttons should be displayed.
Return: array
wc_social_login_{provider_id}_hybridauth_config
Filter provider’s HybridAuth configuration.
Return: array
wc_social_login_profile_identifier
Filter the profile identifier displayed to the user.
Return: string

Action Reference ↑ Back to top

wc_social_login_load_providers
Providers can register themselves through this hook.
wc_social_login_user_authenticated
Fired when user authenticated via social login. Parameters: user ID, provider ID (string, ie ‘twitter’)
wc_social_login_account_unlinked
Fired when user unlinks a social login profile. Parameters: user ID, provider ID (string, ie ‘twitter’)
wc_social_login_user_account_linked
Social login linked to user account. This hook is called when a social login is first linked to a user account. Parameters: user ID, provider ID (string, ie ‘twitter’)
wc_social_login_update_customer_billing_profile
"wc_social_login_{$provider_id}_update_customer_billing_profile"
Update customer billing profile. Parameters: user ID, \WC_Social_Login_Provider_Profile profile instance

Function Reference ↑ Back to top

woocommerce_social_login_link_account_buttons( $return_url = null )
Outputs “link account” buttons only to logged-in users
woocommerce_social_login_buttons( $return_url = null )
Outputs “create account” buttons only to non-logged-in users
wc_social_login()->get_frontend_instance()->get_login_buttons_html( $return_url = '' )
Returns HTML for the login buttons

Samples ↑ Back to top

Most functions in Social Login are accessible to developers, and can be removed and re-added as desired. The frontend class can be accessed with:

wc_social_login()->get_frontend_instance()

while the admin class can be accessed with:

wc_social_login()->get_admin_instance()

(which could allow you to remove settings or reports).

Sample: Edit Roles for Automatic Account Linking

If a logged-out customer tries to log in with a social network that uses the customer’s site account email, these accounts will be linked automatically and the customer will be logged in (same goes for the subscriber role). However, other user roles on your site will not automatically link for security — we have an explanation of why here.

If you want to allow automatic linking by email for other roles, such as perhaps a wholesaler role you’ve added, you can enable other roles by slug with the wc_social_login_find_by_email_allowed_user_roles filter, which by default allows 2 roles:

array( 'subscriber', 'customer' )
function wc_social_login_email_link_additional_roles( $roles ) {
    $roles[] = 'wholesale-customer';
    return $roles;
}
add_filter( 'wc_social_login_find_by_email_allowed_user_roles', 'wc_social_login_email_link_additional_roles' );

Sample: Move Social Login Buttons

In the My Account section, you could move the social profiles in the account section by unhooking them and re-hooking them where you choose to. Here’s an example that removes them from the edit account section to the dashboard (WC 2.6+).

You can move buttons on the registration / login forms as well. By default, buttons are added to the end of the “log in” form, as registration forms aren’t always shown, and buttons work for both log in and registering new accounts. This will move them to the “registration” form instead.

Sample: Add Social Login to WP Login / Registration

This document is provided as a courtesy for developers and designers. Please note that we do not support or offer customization services as part of our support policy. Any sample code provided is simply for reference.

WooCommerce - the most customizable eCommerce platform for building your online business.

Back to the top