Multi-user blog woblog integrates third-party user database

rate:
0
(0user)

This time we will talk about how multi-user blog woblog integrates third-party user databases. For example, verysource.com already had a ucenter user database before the blog was built. If the blog uses a separate user database, the website users will be completely separated. A unified user database must be used. So the final solution is to use ucenter’s library for blogs.

To make this modification, it is necessary to modify the login mechanism of woblog. Since woblog is modified and optimized based on wordpress, the following methods are also applicable to wordpress:

1. Modify the wp-includes/pluggable.php file and find the following code:

function wp_validate_auth_cookie( $cookie = '', $scheme = '' ) {

WordPress also uses cookies to determine the user’s login status. We first rename this function for future use, and then rebuild a function with the same name and write your own code to determine the login, such as the following:

//Custom modification, use dicsuz cookie authentication instead of wp
function wp_validate_auth_cookie( $cookie = '', $scheme = '' ) {
    //Determine whether to log in
    $uid = get_uid(false);
    if(!$uid){
        return false;
    }else{
        return $uid;
    }
}

The method get_uid is the code for judging whether the user is logged in through the cookie of discuz, which can be placed in the public method library file functions.php of wp.

This article is an original article, please indicate the source for reproduced!

Register or verify your account before rate!

Leave a Reply