if( $userId == 0 ) { // Generate a login url $url = $facebook->getLoginUrl( array( 'scope' => 'email, user_status' ) ); ... Your Login button ... } else { // Get user's info $userdata = $facebook->api( '/me' ); $data = array( 'first_name' => $userdata['first_name'], 'last_name' => $userdata['last_name'], 'username' => $userdata['username'], 'email' => $userdata['email'], 'languages' => $userdata['languages'], 'locale' => $userdata['locale'], 'timezone' => $userdata['timezone'], 'gender' => $userdata['gender'], 'location' => $userdata['location'], 'hometown' => $userdata['hometown'], ); print_r( $data ); }