WordPress.org

Ready to get started?Download WordPress

Forums

user mysteriousl got logged out, why? (1 post)

  1. dragon52x
    Member
    Posted 8 months ago #

    Hello,

    I have a web page to update the db but I want only one person (name XX) to do it. So I check the user name like this

    global $current_user;
        $current_user = wp_get_current_user();
    
        echo 'username is: ' . $current_user->user_login . ';';
    
        if ($current_user->user_login != "XX") {
            $return = new WP_Error('11', __('You can't update.') );
        }

    here I have added a debug line 'echo' to display the user name.

    Here is what happens:

    The user logs in, select the web page. The name XX is displayed indicating the user is logged in. eg 'username is: XX;'.

    The user fills the form on the page, click the update button but the user name is now missing. The $current_user object is now empty. He is no longer logged in! eg 'username is:;'

    How is that possible, all within the same web page? I don't know wp enough to understand how user got logged out.

    Can anyone help?

    Thanks

    PS, I have installed
    http://wordpress.org/extend/plugins/theme-my-login/

Reply

You must log in to post.

About this Topic