Comments on: Authenticating with WordPress 2.6 (part 3) http://2718.us/blog/2008/08/03/authenticating-with-wordpress-26-part-3/ Miscellaneous Technological Geekery Sun, 28 Feb 2010 01:51:21 +0000 hourly 1 http://wordpress.org/?v=3.0.4 By: 2718.us http://2718.us/blog/2008/08/03/authenticating-with-wordpress-26-part-3/comment-page-1/#comment-134 2718.us Fri, 13 Mar 2009 16:38:32 +0000 http://2718.us/blog/?p=82#comment-134 @roberto What I've done where I tied into WP authentication is: <pre>require_once('/path/to/wp-config.php'); if (!is_user_logged_in()) auth_redirect(TRUE); $wp_user_record = wp_get_current_user(); $username = $wp_user_record->user_login;</pre> That is to say, I've done it by including WordPress's functions and calling wp_get_current_user() to get the user record and go from there. Given the username, there are certainly ways to go about extracting info from the database directly (which avoids the memory usage of loading up all of WP) and I think you can get the username from the cookies themselves (you'd have to have your scripts know about the WP cookie name stuff), but once you start tying into the system at that kind of lower level, the risk of major headaches on WP upgrades increases substantially. @roberto
What I’ve done where I tied into WP authentication is:

require_once('/path/to/wp-config.php');
if (!is_user_logged_in()) auth_redirect(TRUE);
$wp_user_record = wp_get_current_user();
$username = $wp_user_record->user_login;

That is to say, I’ve done it by including WordPress’s functions and calling wp_get_current_user() to get the user record and go from there.

Given the username, there are certainly ways to go about extracting info from the database directly (which avoids the memory usage of loading up all of WP) and I think you can get the username from the cookies themselves (you’d have to have your scripts know about the WP cookie name stuff), but once you start tying into the system at that kind of lower level, the risk of major headaches on WP upgrades increases substantially.

]]>
By: roberto http://2718.us/blog/2008/08/03/authenticating-with-wordpress-26-part-3/comment-page-1/#comment-132 roberto Fri, 13 Mar 2009 00:02:22 +0000 http://2718.us/blog/?p=82#comment-132 Once a WP user is authenticated, is there a session variable that the scripts can use to identify the user? (i.e., to grab user specific data from the db) Once a WP user is authenticated, is there a session variable that the scripts can use to identify the user? (i.e., to grab user specific data from the db)

]]>
By: Maski http://2718.us/blog/2008/08/03/authenticating-with-wordpress-26-part-3/comment-page-1/#comment-101 Maski Thu, 02 Oct 2008 15:50:36 +0000 http://2718.us/blog/?p=82#comment-101 Well.. i was afraid about that. My second guess is to build a custom comments syst only using wp authentication. Thanks Well.. i was afraid about that. My second guess is to build a custom comments syst only using wp authentication.

Thanks

]]>
By: 2718.us http://2718.us/blog/2008/08/03/authenticating-with-wordpress-26-part-3/comment-page-1/#comment-99 2718.us Wed, 01 Oct 2008 23:43:14 +0000 http://2718.us/blog/?p=82#comment-99 @maski: I don't really know much about the inner workings of the comment system. I haven't tried to use it outside of WP at all. At a guess (without looking at the code at all), I'd suspect that comments are tied to entries by some sort of entry id number and trying to integrate that with non-WP pages could be problematic. I don't know the details of your implementation, but it might be easier to use WordPress as the core of the whole site, use pages for whatever you had outside WP that you wanted comments on, and then add in whatever else you want. @maski:
I don’t really know much about the inner workings of the comment system. I haven’t tried to use it outside of WP at all. At a guess (without looking at the code at all), I’d suspect that comments are tied to entries by some sort of entry id number and trying to integrate that with non-WP pages could be problematic.

I don’t know the details of your implementation, but it might be easier to use WordPress as the core of the whole site, use pages for whatever you had outside WP that you wanted comments on, and then add in whatever else you want.

]]>
By: Maski http://2718.us/blog/2008/08/03/authenticating-with-wordpress-26-part-3/comment-page-1/#comment-98 Maski Wed, 01 Oct 2008 23:00:11 +0000 http://2718.us/blog/?p=82#comment-98 Hi, this is just what I was looking for!!! Thanks Now, Im working on the other site to have authentication based on my blog, what would I need to be able to use WPs comment system on this other site? Just copy my themes comments file? I know that since the other sites articles or posts arent inside wp that could be a problem, what whould you suggest? Hi, this is just what I was looking for!!! Thanks

Now, Im working on the other site to have authentication based on my blog, what would I need to be able to use WPs comment system on this other site? Just copy my themes comments file?

I know that since the other sites articles or posts arent inside wp that could be a problem, what whould you suggest?

]]>
By: 2718.us http://2718.us/blog/2008/08/03/authenticating-with-wordpress-26-part-3/comment-page-1/#comment-96 2718.us Wed, 01 Oct 2008 06:00:56 +0000 http://2718.us/blog/?p=82#comment-96 @jc min: I'm assuming, given that you commented on this post, that you're using WP2.6.x in both blogs. The best I can think of off the top of my head (given that it's 1am) is more or less along the lines of my solution to the issue of integrating bbPress 0.9.0.2 with WP2.6.x--that is, use a carefully-crafted plugin in both installs that sets and clears the appropriate cookies for the other install. The setting-cookies end is easier, since there's an action hook, whereas the clearing-cookies bit requires overriding a pluggable function. If this makes some sense to you and you're interested in trying it, follow up with another comment and I'll dig out the details. @jc min:
I’m assuming, given that you commented on this post, that you’re using WP2.6.x in both blogs. The best I can think of off the top of my head (given that it’s 1am) is more or less along the lines of my solution to the issue of integrating bbPress 0.9.0.2 with WP2.6.x–that is, use a carefully-crafted plugin in both installs that sets and clears the appropriate cookies for the other install.

The setting-cookies end is easier, since there’s an action hook, whereas the clearing-cookies bit requires overriding a pluggable function.

If this makes some sense to you and you’re interested in trying it, follow up with another comment and I’ll dig out the details.

]]>
By: jc min http://2718.us/blog/2008/08/03/authenticating-with-wordpress-26-part-3/comment-page-1/#comment-94 jc min Wed, 01 Oct 2008 05:48:34 +0000 http://2718.us/blog/?p=82#comment-94 you seem to know alot about wordpress cookies and hoping you can help me and the rest of wordpress community that wants to do this tweak!. currently have two wordpress running on a single database with different prefix and shared user tables. 1st blog is on www.example.com and second is on www.example.com/directory/ is there anyway i can make it so if i logon to example.com it logs me on to directory automatically? thus = single signon? you seem to know alot about wordpress cookies and hoping you can help me and the rest of wordpress community that wants to do this tweak!.

currently have two wordpress running on a single database with different prefix and shared user tables.

1st blog is on http://www.example.com and second is on http://www.example.com/directory/

is there anyway i can make it so if i logon to example.com it logs me on to directory automatically? thus = single signon?

]]>
By: 2718.us blog - WordPress 2.6 is Giving Me a Headache http://2718.us/blog/2008/08/03/authenticating-with-wordpress-26-part-3/comment-page-1/#comment-63 2718.us blog - WordPress 2.6 is Giving Me a Headache Mon, 04 Aug 2008 03:30:19 +0000 http://2718.us/blog/?p=82#comment-63 [...] to someone’s website, but WordPress 2.6 is starting to give me a headache.  I’ve already posted thrice about issues with integrating an external site into WP2.6’s user authentication.  Honestly, [...]

[...] to someone’s website, but WordPress 2.6 is starting to give me a headache.  I’ve already posted thrice about issues with integrating an external site into WP2.6’s user authentication.  Honestly, [...]

]]>