The tutorial from the link I provided was destroying the facebook session after login in and creating a new account for some reason. I just had to remove $facebook->destroySession(); from both parts and now everything is working as intended.
Here is the code from the tutorial with both lines commented out.
if ($fbuser) {
$fb_registerpage_name = __('Facebook Register', 'bloora');
$fbpage = get_page_by_title( $fb_registerpage_name );
if(isset($user_profile['email'])){
$user_name = $user_profile['email'];
$user_email = $user_profile['email'];
$user_id = username_exists( $user_name );
if ( !$user_id and email_exists($user_email) == false ) {
$random_password = wp_generate_password( $length=12, $include_standard_special_chars=false );
$user_id = wp_create_user( $user_name, $random_password, $user_email );
wp_set_current_user( $user_id );
wp_set_auth_cookie( $user_id );
// $facebook->destroySession(); THIS HAS TO BE REMOVED
} else {
$random_password = __('User already exists. Password inherited.');
wp_set_current_user( $user_id );
wp_set_auth_cookie( $user_id );
// $facebook->destroySession(); THIS HAS TO BE REMOVED!
}
}else{
if(!is_admin() && isset($_POST) && count($_POST) > 0){
if($fbpage){
echo '<script>if(window.location.href != "'.get_permalink($fbpage->ID).'"){ window.location.href = "'.get_permalink($fbpage->ID).'"; }</script>';
}else{
// Create post object
$my_post = array(
'post_title' => $fb_registerpage_name,
'post_content' => 'This is my post.',
'post_status' => 'publish',
'post_type' => 'page',
'post_author' => 1
);
// Insert the post into the database
$fbpage = wp_insert_post( $my_post );
echo '<script>if(window.location.href != "'.get_permalink($fbpage->ID).'"){ window.location.href = "'.get_permalink($fbpage->ID).'"; }</script>';
}
}
}
}