2718.us blog » wordpress login http://2718.us/blog Miscellaneous Technological Geekery Tue, 18 May 2010 02:42:55 +0000 en hourly 1 http://wordpress.org/?v=3.0.4 WordPress Authentication Gotcha: bbPress Integration http://2718.us/blog/2008/04/20/wordpress-authentication-gotcha-bbpress-integration/ http://2718.us/blog/2008/04/20/wordpress-authentication-gotcha-bbpress-integration/#comments Mon, 21 Apr 2008 04:42:51 +0000 2718.us http://2718.us/blog/?p=24 I not only wanted to integrate my own other things into my WordPress-based site, but I wanted forums, too, so of course I thought of bbPress.  It seems to integrate well with WordPress, but then suddenly strange things started happening with login and logout.  For instance, when I logged in with bbPress, I couldn’t get WordPress to log me out and my integrated site didn’t work.

Ah-ha!  A cookie problem–while I’d set the cookie domain for WordPress to allow subdomains to work, bbPress didn’t know about WordPress’s cookie settings, so bbPress didn’t set the right cookie domain.  Worse, this meant that the cookie didn’t quite match up to what WordPress expected, so logging out in WordPress tried to blank a cookie that wasn’t set, not the login cookie set by bbPress.  The fix is to add something like

$bb->cookiedomain = '.yoursite.com';

to bb-config.php (that is, match what you’ve set in WordPress). Not the most obvious way to set an option, but it works.

]]>
http://2718.us/blog/2008/04/20/wordpress-authentication-gotcha-bbpress-integration/feed/ 1
Using WordPress for User Authentication http://2718.us/blog/2008/04/12/using-wordpress-for-user-authentication/ http://2718.us/blog/2008/04/12/using-wordpress-for-user-authentication/#comments Sun, 13 Apr 2008 04:56:37 +0000 2718.us http://2718.us/blog/?p=15 Plenty of people seem to have written a lot about how to make WordPress use some other program’s user authentication mechanism, but there seems to be fairly little on how to get at WordPress’s user authentication from some other program.  Fortunately, I found this article, and got what I wanted.

It’s a fairly straight-forward process.  At its simplest:

require_once('wp-config.php');
  1. auth_redirect();

Including wp-config.php (you may have to watch the path) gets you just about all of WordPress and auth_redirect() will check if the user is logged in to WordPress and if not, they get bounced to a login form.

Where things get trickier is if you want to use the authentication on a subdomain (you have to tweak COOKIE_DOMAIN in wp-config.php [to override what’s already in wp-settings.php) or if your blog is in a subdirectory and you want the authentication outside that subdirectory (try tweaking COOKIEPATH).

Oh, and if you try to put the require_once() statement inside a function, you will also need

global $wpdb;

or nothing will work.

The issue of how much memory it consumes to load all of WordPress just to authenticate users is a whole separate issue.

]]>
http://2718.us/blog/2008/04/12/using-wordpress-for-user-authentication/feed/ 4