我提供的链接中的教程是在登录并出于某种原因创建新帐户后销毁facebook会话。我只需删除$facebook->destroySession();从这两部分开始,现在一切都按预期进行。
下面是教程中的代码,注释掉了这两行代码。
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>\';
}
}
}
}