Your address will show here +12 34 56 78

Home Forums WP ESTATE – Real Estate WordPress Theme FORUM Google Login not working Reply To: Google Login not working



I have found the issue and its fix. I hope people would get help from this. In wpresidence/libs/3rdparty.php

After Google provide you with the access token, it gets information from your User’s google profile. As we all know google have an option to display nickname as well and and full name is like NAME (Nick). and they are setting full name as your username but wordpress doesn’t allow brackets () in username. So i just extract the username from email and set it as wordpress username. below is code to fix the issue you can copy and replace the code in above mentioned file. I hope i helped.

/// estate_google_oauth_login  Login
if( !function_exists('estate_google_oauth_login') ):

function estate_google_oauth_login($get_vars){
    set_include_path( get_include_path() . PATH_SEPARATOR . get_template_directory().'/libs/resources');
    $allowed_html   =   array();
    require_once 'src/Google_Client.php';
    require_once 'src/contrib/Google_Oauth2Service.php';
    $google_client_id       =   esc_html ( get_option('wp_estate_google_oauth_api','') );
    $google_client_secret   =   esc_html ( get_option('wp_estate_google_oauth_client_secret','') );
   $google_redirect_url    =   get_dashboard_profile_link();
    $google_developer_key   =   esc_html ( get_option('wp_estate_google_api_key','') );

    $gClient = new Google_Client();
    $gClient->setApplicationName('Login to GwadarLinks');
    $google_oauthV2 = new Google_Oauth2Service($gClient);
    if (isset($_GET['code'])) { 

    if ($gClient->getAccessToken()) 
        $allowed_html      =   array();
        $dashboard_url     =   get_dashboard_profile_link();
        $user              =   $google_oauthV2->userinfo->get();
        $user_id           =   $user['id'];		
		$split_email = explode( '@' , $user['email']);
		$custom_username = $split_email[0];
		$full_name         =   wp_kses($user['name'], $allowed_html);
        $email             =   wp_kses($user['email'], $allowed_html);

        $profile_url                      = filter_var($user['link'], FILTER_VALIDATE_URL);
        $profile_image_url                = filter_var($user['picture'], FILTER_VALIDATE_URL);
        $full_name=  str_replace(' ','.',$full_name);  

        wp_set_password( $code, $wordpress_user_id ) ;
        $info                   = array();
        $info['user_login']     = $custom_username;
        $info['user_password']  = $code;
        $info['remember']       = true;
        $user_signon            = wp_signon( $info, false );
        if ( is_wp_error($user_signon) ){ 
            wp_redirect( home_url() );  

endif; // end   estate_google_oauth_login