Code Snippets Developer API


function wsl_lower_default_permissons( $provider_scope, $provider )
{
    if( 'facebook' == strtolower( $provider ) )
    {
        $provider_scope = 'email'; // should not be empty or it will be overwritten
    }

    if( 'google' == strtolower( $provider ) )
    {
        $provider_scope = 'profile'; // should not be empty or it will be overwritten
    }

    return $provider_scope;
}

add_filter( 'wsl_hook_alter_provider_scope', 'wsl_lower_default_permissons', 10, 2 );

In order for the buttons to display correctly in this example, Font Awesome should be integrated into your website theme.

function wsl_use_fontawesome_icons( $provider_id, $provider_name, $authenticate_url )
{
   ?>
   <a
      rel           = "nofollow"
      href          = "<?php echo $authenticate_url; ?>"
      data-provider = "<?php echo $provider_id ?>"
      class         = "wp-social-login-provider wp-social-login-provider-<?php echo strtolower( $provider_id ); ?>"
    >
      <span>
         <i class="fa fa-<?php echo strtolower( $provider_id ); ?>"></i>
         Sign in with <?php echo $provider_name; ?>
      </span>
   </a>
<?php
}

add_filter( 'wsl_render_auth_widget_alter_provider_icon_markup', 'wsl_use_fontawesome_icons', 10, 3 );

Solution contributed by Yitzi on WordPress support forum https://wordpress.org/support/topic/woocommerce-does-it-work?replies=3#post-5474168.

Note: I didn't personally test this code. It's listed here in the only hope that it will help.

// display WSL widget in woocommerce forms
add_action( 'woocommerce_before_customer_login_form', 'wsl_action_wordpress_social_login' );
add_action( 'woocommerce_before_checkout_form'      , 'wsl_action_wordpress_social_login' );

/**
* Our hooked in function - $fields is passed via the filter
*/
function custom_override_checkout_fields( $fields )
{
	$current_user = wp_get_current_user();

	$fields['billing']['billing_first_name']['default'] = $current_user->user_firstname;
	$fields['billing']['billing_last_name']['default']  = $current_user->user_lastname;

 	return $fields;
}

add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );

This is a very basic integration. The code below will add WSL widget into EDD login and register forms.

add_action( 'edd_checkout_login_fields_after'  , 'wsl_action_wordpress_social_login' );
add_action( 'edd_register_account_fields_after', 'wsl_action_wordpress_social_login' );

This is a very basic integration. The code below will add 100 points to each new WSL user.

function mycred_award_wsl_users_signup( $user_id, $provider, $hybridauth_user_profile )
{
	if( ! function_exists( 'mycred_add' ) )
	{
		return;
	}

	mycred_add(
		'registration',
		$user_id,
		100,
		'Points for signing up through ' . $provider
	);
}

add_action( 'wsl_hook_process_login_after_create_wp_user', 'mycred_award_wsl_users_signup', 10, 3 );
function get_access_tokens( $user_id, $provider, $hybridauth_user_profile )
{
    include_once( WORDPRESS_SOCIAL_LOGIN_ABS_PATH . '/hybridauth/Hybrid/Auth.php' );

    try
    {
        $provider = Hybrid_Auth::getAdapter( $provider );

        # oauth 1 and 2
        $access_token = $provider->adapter->token( 'access_token' );

        # oauth 1
        $access_token_secret = $provider->adapter->token( 'access_token_secret' );
    }
    catch( Exception $e )
    {
        echo "Ooophs, we got an error: " . $e->getMessage();
    }
}
add_filter( 'wsl_hook_process_login_before_wp_set_auth_cookie', 'get_access_tokens', 10, 3 );


Please, do not submit issues here.

This comment section is for a general question and feedback. If you want to report a bug, please refer to the Support section.