The MU forums have moved to WordPress.org

Cookies outside the loop (7 posts)

  1. sgrunt
    Member
    Posted 13 years ago #

    I have an MU site, but my homepage it is outside MU. I actually show a login form for logging from the home into MU, but it's a static form. I'd like that users don't see the login form if they are already logged in MU. There is a way to do that? Thanx

  2. tdjcbe
    Member
    Posted 13 years ago #

    I spent a good while trying to find a walkthru on this but nothing came up. Rather surprised about that.

    It's my understanding that if you call the file wp-blog-header.php from your site elsewhere, you can have access to the wordpress functions and can then do a check for is_user_logged_in or whatever the check is. Haven't tried this but it's worth a shot.

    Take a look at your index.php file found within your mu install's route for how wpmu does this call.

    Hoep this helps

  3. andrea_r
    Moderator
    Posted 13 years ago #

    Yep.

    http://codex.wordpress.org/Creating_a_Static_Front_Page#Include_the_Header

    I have done this, but not had the login form.

  4. cafespain
    Member
    Posted 13 years ago #

    And/Or - Follow through the WordPress MU code to find the bit that checks the cookies and copy that into your static page.

    The function is is_user_logged_in(), so search the mu code for "function is_user_logged_in()" and see what it does, if it calls another function search for that. At some point you will either get down to the nitty gritty, or you will find a php file that you can include in your home page and call the functions from it.

    That's the way I work out most things, and it gives you a good understanding of the way WordPress functions.

  5. tdjcbe
    Member
    Posted 13 years ago #

    We had a thread a few days ago on this but I can't find it. The code where it actually looks for the cookie is in the pluggable.php file. I *think* that's in the wp-includes subdirectory but I'm not in a position to double check.

    Probably would be better to do just the cookie check as running the wp code would require processor power.

    Gotta admit that if it came down to it, I'd lean towards loading the blog header file and doing the check. That's like two lines of code vs spending the time digging through the code looking for what you would need to do. I'm a lazy SOB though.

    Really would depend on what would work for you. Cafe is right though. It would be a good learning experience.

  6. andrea_r
    Moderator
    Posted 13 years ago #

    Reading the code is awesome. All kinds of goodies in there.

  7. kunal17
    Member
    Posted 13 years ago #

    The codex page linked to above mentions that it might be outdated. Does anyone have more updated resources on how to load wordpress functions outside of wordpress?

About this Topic