• Resolved vineetsen

    (@vineetsen)


    Hi
    First of all thank you for the great plugin!
    Really saved me a lot of hard work.

    The issue I’m facing is that I want to reduce the number of permissions being asked of facebook users.

    I followed the documentation and tried using the filter wsl_hook_alter_provider_scope.

    In the documentation, the following example is given:

    function wsl_lower_facebook_permissons( $provider_scope, $provider )
    {
    if( ‘facebook’ == $provider )
    {
    # https://developers.facebook.com/docs/facebook-login/permissions
    $provider_scope = ’email, user_about_me’;
    }

    return $provider_scope;
    }
    add_filter( ‘wsl_lower_facebook_permissons’, ‘wsl_lower_facebook_permissons’ );

    I changed it according to my needs, following is my code:

    function wsl_lower_facebook_permissons( $provider_scope, $provider )
    {
    if( ‘facebook’ == $provider )
    {
    # https://developers.facebook.com/docs/facebook-login/permissions
    $provider_scope = ’email, public_profile’;
    }

    return $provider_scope;
    }
    add_filter( ‘wsl_hook_alter_provider_scope’, ‘wsl_lower_facebook_permissons’ );

    PS: I figured the add filter line in the example has an error, so I changed it in my code.

    I added this code to the functions.php file of the theme.

    But the problem is that it’s not working.
    Can you please guide me in the right direction?

    Much appreciated! ??

    https://www.ads-software.com/plugins/wordpress-social-login/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Miled

    (@miled)

    actually there is more than one error on that example, let me explain.

    by default, wsl will ask for the user public profile (id, name, gender, etc), friend list, email address, birthday, hometown, website and personal description.

    and in case you want to ask for fewer permissions, the filter should be implemented like this:

    function wsl_lower_facebook_permissons( $provider_scope, $provider )
    {
        if( 'facebook' == strtolower( $provider ) ) // < strtolower
        {
            $provider_scope = 'email'; // should not be empty or it will be overwritten
        }
    
        return $provider_scope;
    }
    
    add_filter( 'wsl_hook_alter_provider_scope', 'wsl_lower_facebook_permissons', 10, 2 );

    this example above will requires wsl to just ask for user public profile, friend list and email address.

    if you are wondering why it still asking for the friend list, well that’s because facebook considers your public profile and friendlist as part of your basic info and he gives it away whether you ask or not.

    hope this helps.

    Thread Starter vineetsen

    (@vineetsen)

    Thanks a lot!
    Worked like a charm! ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Reduce facebook permissions using wsl_lower_facebook_permissons’ is closed to new replies.