Facebook login
-
Can anyone tell me why this code will not pull userdata when they login with facebook i can only get it to pull there name for user-login but nothing else
public function __construct( ZM_Dependency_Container $di ){
$this->prefix = ‘zm_alr_social_facebook’;
$this->_zm_alr_helpers = $di->get_instance( ‘helpers’, ‘ALRHelpers’, null );add_action( ‘wp_ajax_facebook_login’, array( &$this, ‘facebook_login’ ) );
add_action( ‘wp_ajax_nopriv_facebook_login’, array( &$this, ‘facebook_login’) );
add_action( ‘wp_head’, array( &$this, ‘head’ ) );add_filter( ‘get_avatar’, array( &$this, ‘load_fb_avatar’ ) , 1, 5 );
add_filter( ‘zm_alr_login_above_fields’, array( &$this, ‘aboveLoginFields’ ) );
add_filter( ‘zm_alr_register_above_fields’, array( &$this, ‘aboveLoginFields’ ) );
add_filter( ‘zm_alr_social_settings_fields_tab’, array( &$this, ‘settings’ ) );}
/**
* Maps our FB response fields to the correct user fields as found in wp_update_user. Then
* calls setUpNewFacebookUser, and passes the correct response via JSON to JS.
*
* @since 2.0.0
*
* @return JSON A JSON object
*/
public function facebook_login(){check_ajax_referer( ‘facebook-nonce’, ‘security’ );
$user = apply_filters( ‘fbl/user_data_login’, array(
‘username’ => $_POST[‘fb_response’][‘id’],
‘user_login’ => $_POST[‘fb_response’][‘name’],
‘first_name’ => $_POST[‘fb_response’][‘first_name’],
‘last_name’ => $_POST[‘fb_response’][‘last_name’],
‘user_email’ => $_POST[‘fb_response’][’email’],
‘user_url’ => $_POST[‘fb_response’][‘link’],
‘fb_id’ => $_POST[‘fb_response’][‘id’]
));if ( empty( $user[‘username’] ) ){
$status = $this->_zm_alr_helpers->status(‘invalid_username’);
$user_id = false;} else {
$user_obj = get_user_by( ‘login’, $user[‘user_login’] );
if ( $user_obj == false ){
$user_obj = $this->setupNewFacebookUser( $user );
}
// A WP user account already exists that is NOT associated with a FB account
if ( $user_obj == ‘existing_user_email’ ){$status = $this->_zm_alr_helpers->status(‘username_exists’);
} elseif ( $user_obj ){
$user_id = $user_obj->ID;
wp_set_auth_cookie( $user_id, true );
$status = $this->_zm_alr_helpers->status(‘success_login’);} else {
$status = $this->_zm_alr_helpers->status(‘invalid_username’);
}
}
- The topic ‘Facebook login’ is closed to new replies.