• Resolved mandawgus

    (@mandawgus)


    Hi all,
    I’ve googled this topic many times and still haven’t come up with a satisfactory answer. I’m currently working on a site that has both a blog and a forum that run off of wordpress. The site also has a bunch of functionality that I handcoded outside of wordpress. I’m currently looking to add a login bar at the top of the screen so that no matter what page a person is on (blog, forum, or main) the person can always log in and out of the site. I already figured out the forum and blog parts because they are common sense. I’ve tried importing the wp-blog-header() and calling wp-head(). This allows me to log someone in. The problem is that once they are logged in, I need a way to check to make sure they are logged in (so I can display logout links, allow access to content, etc…). I’ve written a function that does this in wordpress’ pluggable.php but I can’t seem to get it to work.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Once you’ve imported wp-blog-header, then all you have to do is to call is_user_logged_in() to check on that.

    Note: There’s a cookie issue here. Your site must be in the same directory as or a subdirectory of the WordPress folder. Otherwise, the browser won’t send the WordPress authentication cookie, and WordPress will not have any idea who the user is.

    Example:
    https://example.com/wordpress
    https://example.com/forum

    If the software in /forum calls /wordpress/wp-blog-header.php, it can get access to the WP functions, but the user will still not be logged in, because their browser never passed the cookie along to the /forum URL. WordPress must be installed in /forum itself, or in the root / directory for that cookie to be passed to calls inside the /forum directory.

    Thread Starter mandawgus

    (@mandawgus)

    Thanks, this was the exact answer that I was looking for.

    Is there any way to set the cookie domain up one level so it can be used by the root folder as well as the wordpress folder?

    For instance, my directory structure is such:

    root/index.php
    root/wordpress/wp-blog-header.php

    Is there a way to set the auth cookie so it can be used by both index.php (which calls wp-blog-header.php) and the wordpress installation? I tried using the COOKIE_DOMAIN constant but it didn’t work, or maybe that’s for something completely different. I couldn’t tell by the documentation, or maybe I’m just [enter your derogation here].

    Never mind. There’s a plugin that does it for you. Of course.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Checking wordpress login status from outside the blog’ is closed to new replies.