• I have an installation of wordpress that I use for the blog and in a directory, I have an application developed in php. To avoid redundancy I use the login of wordpress to get access to this app, so people registered in Wp, can see the content within this app.

    Before the last update to Wp 4.2, it used to work perfectly but now it doesn’t.

    In the header of my PHP I used the following code to get the user_id:

    require_once('../../wp-blog-header.php');
    
    $userID = get_current_user_id();
    print_r($userID);
    if ( $userID<=0 ) {
        //header('location: /login/'); exit(0);
    }

    The question is that now, sometimes work, and sometimes it does not. For instance, if I go to the main site and suddenly go to the folder of the app, it works, but if I enter directly, it doesnt work, the user_id = 0.

    I think something changed the way WP manage the sessions or something like that.

    Does anyone know how can i solve this?

    Thanks in advance.

Viewing 1 replies (of 1 total)
  • Me too faced this problem , i am using this file to make login and register but now doesn`t work !

Viewing 1 replies (of 1 total)
  • The topic ‘Getting the user_id in WP 4.2’ is closed to new replies.