WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Having a strange issue where I am checking for the current user by using the wp_get_current_user command and occasionally, users have reported to seeing the information for another user. Should I be checking for the current user a different way? This is scary because the information that I am displaying for the users is sensitive and I need the system to only show the current user and not another user that is also logged in.

UPDATE: Attached code...

function ssm_dashboard()
    global $wpdb;
    $user = wp_get_current_user();
    echo '<h3>Parent Dashboard</h3>';

    if (current_user_can(SSM_CAPS_APPROVED_USER))
        $ssmuser = $wpdb->get_row( "SELECT id, last_name, first_name FROM " . $wpdb->prefix.SSM_USER_TABLE . " WHERE user_id_1=" . $user->ID, ARRAY_A); 
        echo 'Welcome ' . $ssmuser['first_name'] . ' ' . $ssmuser['last_name'];

So, the code snippet is a widget I created for my plugin that shows a user's dashboard. What is supposed to happen is that once a user logs in, the widget gets the current user's ID, then looks up their account in my table (wp_ssm_user) and returns the row that matches the wp_user->ID and is displayed on the dashboard. Problem is, some users are reporting that when they log in and perform certain functions (I'm awaiting a reply as to which function in particular), they are redirected to the dashboard where a different user's information is displayed.

share|improve this question
Post all of the relevant code please. – s_ha_dum Jun 29 '13 at 16:48
There is no redirect at all in that code so I am leaning toward thinking the real issue is elsewhere. I'll wait for the additional information before speculating more. How is that function called/hooked? – s_ha_dum Jun 29 '13 at 17:41
It's a shortcode. I add the shortcode to a page. And you are correct as far as the redirect. The redirect happens from another shortcode. Not sure it is a valid point, but I did find this question which @Jesse answered with the point of using global $current_user when trying to get the current user information. I was using the wp_get_current_user() method. Not sure if it makes a difference but I am testing it currently. – ClockwiseQ Jun 29 '13 at 18:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.