Index: trunk/include/pluggable-override.php
===================================================================
--- trunk/include/pluggable-override.php	(revision 65)
+++ trunk/include/pluggable-override.php	(revision 69)
@@ -19,12 +19,13 @@
 	global $current_user;
 
-	if (is_root_index_page_call()){
-		if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST )
-			return false;
 
-		if ( ! empty($current_user) )
-			return;
+	if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST )
+		return false;
 
-		if (check_xpress_auth_cookie()){
+	if ( ! empty($current_user) )
+		return;
+
+	if (is_xpress_index_page_call()){
+		if (check_xpress_auth_cookie()){	//The cookie is login user's or it checks it
 			if ( $user = wp_validate_auth_cookie() ) {
 				wp_set_current_user($user);
@@ -33,5 +34,6 @@
 		}				
 		xpress_login();		
-	}else {
+
+	} else {
 		// WP2.7 original
 		if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST )
@@ -60,9 +62,10 @@
 				$u_pass_md5 = $GLOBALS["xoopsUser"]->getVar("pass");		
 				if ( ! empty($u_name) && ! empty($u_pass_md5) ) {		
-//					include_once dirname( __FILE__ ).'/xpress_user.php';
-//					$mess = xpress_user_sync($GLOBALS["xoopsUser"]->getVar("uid"));
-//					if ($mess != 'NOT XPRESS USER'){
+					include_once dirname( __FILE__ ).'/user_sync.php';
+					$messege = '';
+					$ret = xpress_user_sync($GLOBALS["xoopsUser"]->getVar("uid"),$messege);
+					if ($ret){
 						$user = new WP_User(0, $u_name);
-						if ( wp_login($u_name, $u_pass_md5, true) ) {
+						if ( wp_login($u_name, $u_pass_md5) ) {
 							wp_setcookie($u_name, $u_pass_md5, true, '', '', false);
 							do_action('wp_login', $u_name);
@@ -70,5 +73,7 @@
 							return  true;
 						}
-//					}
+					}else {
+						echo $messege;
+					}
 				}
 			}
@@ -88,5 +93,6 @@
 	}
 					
-	if(is_object($GLOBALS["xoopsModule"]) && WP_BLOG_DIRNAME == $GLOBALS["xoopsModule"]->getVar("dirname")){
+	if(is_object($GLOBALS["xoopsModule"])){
+//		&& WP_BLOG_DIRNAME == $GLOBALS["xoopsModule"]->getVar("dirname")){
 		if(is_object($GLOBALS["xoopsUser"])){
 			$u_name = $GLOBALS["xoopsUser"]->getVar("uname");
@@ -107,38 +113,4 @@
 }
 
-
-/*
-
-function wp_login($username, $password, $already_md5 = false) {
-	global $wpdb, $error;
-
-	$username = sanitize_user($username);
-
-	if ( '' == $username )
-		return false;
-
-	if ( '' == $password ) {
-		$error = __('<strong>ERROR</strong>: The password field is empty.');
-		return false;
-	}
-
-	$login = get_userdatabylogin($username);
-	//$login = $wpdb->get_row("SELECT ID, user_login, user_pass FROM $wpdb->users WHERE user_login = '$username'");
-
-	if (!$login) {
-		$error = __('<strong>ERROR</strong>: Invalid username.');
-		return false;
-	} else {
-		if ($login->user_login == $username) {
-				if ($login->user_pass == $password) return true;
-				if ($login->user_pass == md5($password)) return true;
-		}
-
-		$error = __('<strong>ERROR</strong>: Incorrect password.');
-		$pwd = '';
-		return false;
-	}
-}
-*/
 
 // for wordpress2.5
@@ -177,36 +149,4 @@
 }
 
-
-/*
-
-function wp_mail($to, $subject, $message, $from_email="", $from_name="") {
-    $xoopsMailer =& getMailer();
-    $xoopsMailer->useMail();
-    $xoopsMailer->setToEmails($to);
-    $xoopsMailer->setFromEmail( empty($from_email) ? $GLOBALS["xoopsConfig"]['adminmail'] : $from_email);
-    $xoopsMailer->setFromName( empty($from_name) ? $GLOBALS["xoopsConfig"]['sitename'] : $from_name );
-    $xoopsMailer->setSubject($subject);
-    $xoopsMailer->setBody($message);
-    return $xoopsMailer->send();
-}
-
-*/
-/*
-function auth_redirect($force = false, $message = "") {
-	if(!is_object($GLOBALS["xoopsUser"])){
-		header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
-		header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
-		header('Cache-Control: no-cache, must-revalidate, max-age=0');
-		header('Pragma: no-cache');
-	
-		header('Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));
-		exit();
-	}elseif(!empty($force)){
-		$redirect = xoops_getenv("HTTP_REFERER");
-		$redirect = (strpos($redirect, XOOPS_URL) === 0)? $redirect: XOOPS_URL."/".$redirect;
-		redirect_header($redirect, 2, $message);
-	}
-}
-*/
 // ***********************************  End Of Pluggable Function Edit (wp-include/pluggable.php) ************************************
 
