Support » Plugins » Problem in integrating Cake Php and WP:Auto Plogin Plugin

  • Hi friends,

    I have a cakePHP application housing a WP blog. I am using an auto-login plugin to log my users into WP when they sign in to my cake application. This works perfectly fine. But the trouble is, I need this to work the other way round too. That is a) I need my users to get logged in to cake when they log in using WP and b) I need to log users out of WP if they log out of cake and vice versa. I know I can probably achieve this by destroying the wp_auth cookie when I destroy my cake session upon logout. But I am not able to call any WP functions from inside of cake. I tried including the wp-blog-header.php in order to load the WP environment so that I can use the WP variable in Cake but that doesn’t work either”

    Below is the autologin plugin code –

    Plugin Name: Auto Login
    Description: This is a Auto Login plugin works on the Intialization of the WordPress.
    Author: Nishant Shrivastava
    Version: 1.0
    Author URI:
    function auto_login() {
        if (!is_user_logged_in()) {
            //get username
            $user_name = $_SESSION['User']['username']; 
            //get user password
    		$user_pass = md5($_SESSION['User']['password']); 		
    		// Get User's data based on Username to initialize the User session
    		$User = get_userdatabylogin($user_name);
    		$wp_UserID = $User->ID;
    		// Process auto-login
    		wp_set_current_user($wp_UserID, $user_name);
    		do_action('wp_login', $user_name);
    add_action('init', 'auto_login');

    Any help here from you guys is highly appreciated.

  • The topic ‘Problem in integrating Cake Php and WP:Auto Plogin Plugin’ is closed to new replies.