Support » Plugins » Hacks » WordPress Logout From CMS

  • I’ve integrated wordpress into a Content Mgmt Solution (CMS) for a membership site and want to logout the wordpress user from the CMS but am having difficulty figuring out how to do it.

    Here’s the code I’m using to logout the wordpress user from the CMS:
    require_once(‘/blog/wp-config.php’);
    require (“/blog/wp-includes/pluggable.php”);
    if (is_user_logged_in()) {
    wp_logout();
    }

    I’m getting the error: Fatal error: Call to undefined function is_user_logged_in() in /home/eaglehb/public_html/growmyhomebusiness.com/members/logout.php on line 15

    Here’s how I’m logging the wordpress user in w/ modification to the wordpress file header.php.

    if (!is_user_logged_in()) {
    $field=’login’;
    $user_info = get_user_by($field, $_SESSION[SESS_USERNAME]);
    $user_login = $user_info->user_login;
    $user_level = $user_info->user_level;
    $user_id = $user_info->ID;
    wp_set_current_user($user_id);
    wp_set_auth_cookie($user_id);
    do_action(‘wp_signon’, $user_id);
    }

    Your guidance is greatly appreciated ….. Rick

  • The topic ‘WordPress Logout From CMS’ is closed to new replies.