WordPress整合Ucenter最简单的实现方法

如今啊,这程序啊,你不整合UC,那都显得有点OUT啦,连国外的wordpress当然也不能例外。就这嗜好。
Using it, you can easily integrate wordpress with ucenter.

方法一:最简单的整合

<?php
/*
Plugin Name: Discuz Integration
Plugin URI:  http://blog.the17th.net/2007/11/16/discuz-integration/
Description:  User integration with Discuz.
Author:  Alex
Version: 0.2.1
Author URI:  http://the17th.net
*/
define('UC_DBTABLEPRE', '`dz`.uc_');

require_once( ABSPATH . WPINC . '/registration.php');

function add_user_from_discuz() {

if ( validate_username( $_POST['log'] ) && !username_exists( $_POST['log'] ) ) {
$sql = 'SELECT `username`, `password`, `email`, `salt`
FROM ' . UC_DBTABLEPRE . '.`members`
WHERE `username` = \'' . $_POST['log'] . '\'
LIMIT 1';
$result = mysql_query($sql);

while($row = mysql_fetch_array($result)){
if (md5(md5($_POST['pwd']).$row['salt']) == $row['password']) {
wp_create_user($_POST['log'], $_POST['pwd'], $row['email']);
return true;
}
}
}
return false;
}

function loose_sanitize($username, $strict = false) {
return $strict;
}

add_action('wp_authenticate', 'add_user_from_discuz');

/* uncomment to add support to non-ASCII characters in usernames. */
// add_filter('sanitize_user', 'loose_sanitize', 1, 2);

?>

方法二:ucenter integration
http://wordpress.org/extend/plugins/ucenter-integration/

ucenter-integration screenshot 1
setting

ucenter-integration screenshot 2
message component

ucenter-integration screenshot 3
friend component

ucenter-integration screenshot 4
credit component

Leave a Reply