• I wonder if there is a simple way to check if user is logged in without have to load entire wp core.

    I’m working on a flash aplication that give some extra options to users who are logged in on my wordpress blog. To check that, the flash send POST and get a XML which says if user is logged in or not.

    I’d like to load this XML fastest as possible. But to load entire wp core takes several seconds.

    I found out that the constant SHORTINIT is suppose to load only the main core, but setting it to true I can’t use get_currentuserinfo() anymore.

    I’m wondering if someone has even tried to check the user credentials without have to load the core.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter carlla

    (@carlla)

    I’m searching for a faster way to check user is logged in.

    That is what I have tried:

    // my_xml_response.php
    define('SHORTINIT', true);
    require_once('./wp-load.php');
    if(!function_exists('get_currentuserinfo')){
     require( ABSPATH . WPINC . '/formatting.php' );
     require( ABSPATH . WPINC . '/capabilities.php' );
     require( ABSPATH . WPINC . '/user.php' );
     require( ABSPATH . WPINC . '/meta.php' );
     require( ABSPATH . WPINC . '/pluggable.php' );
     wp_cookie_constants( );
    }
    get_currentuserinfo();
    echo "<wp>".$current_user->user_login."</wp>";

    It takes about 5 seconds to load the content. Someone has any suggestion about how to make it faster?

    I am considering try to check the cookies directly. How can I do this?

    @carlla,

    have you tried routing your request through admin-ajax.php?

    R’

    Thread Starter carlla

    (@carlla)

    @rspindel,

    Yes, I did it. That was what I did first. But the ajax response takes about 10 seconds to load. I think it is because load plugins, etc.. things that I don’t need to for while. I guess whitout this things the ajax response could be faster. So I tried the SHORTINIT constant.

    I need to identify the moment when the user does logged out. That is why it need to be fast.

    Well, for while I am using the SHORTINIT constant until find something else.

    Thanks for your response =]

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Short init to check if user is logged in’ is closed to new replies.