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/

转载请注明出处:https://www.onexin.net/wordpress-integration-of-the-most-simple-implementation-ucenter/

相关文章:

1、Magento整合Ucenter实战百万会员篇
https://www.onexin.net/magento-integration-ucenter-real-million-members-articles/

2、整合程序注册时自动激活DZX会员 for discuz!X 1.5
https://www.onexin.net/up-the-integration-process-is-automatically-activated-when-the-dzx-member-for-discuz-x-1-5/

3、如何发布插件或模板到 WordPress 官方网站
https://www.onexin.net/add-your-plugin-to-wordpress/

4、WordPress更换网站域名
https://www.onexin.net/wordpress-change-domain/

5、WordPress中mo和po文件编辑与转换
https://www.onexin.net/wordpress-mo-and-po-file-editing-and-conversion/

Leave a Reply