Featured Articles

Milan Petrovic Interview

This interview is the third in a series of interviews with outstanding WordPress Developers. This ti[...]

9-month status – 4 automated “health” sites

Status on how the 4 automatic sites test has been doing. See both traffic growth and earnings for al[...]

{ 10 comments… read them below or add one }

searbe June 30, 2009 at 04:56

Fantastic :) Needed this so users can be logged in after an ajax-based registration. Thanks for taking the time to post it

Reply

myWordPress June 30, 2009 at 08:29

You are welcome, glad you like it and commented. Comments like this motivate me to continue distributing tips and tricks when I encounter them.

Best of luck with the code, glad it helped :-)

Reply

Patricia Jocobi October 22, 2009 at 18:36

This is great, just what I was looking for, Thanks a lot!

I will use it to integrate a blog using Wordpress to my site, I’ve already have a user login authentication, and don’t to use wordpress login

I’m populating my site users table to wp_user table

Do you think I would have a security issue if I use it for this purpose?

Reply

myWordPress October 23, 2009 at 07:28

I don’t think there would be a security issue as such, obviously you need to secure your own login-system, but if you already do that, the data you send to WordPress should be fine.

You should also note that by maintaining a separate user-login system, you have two databases you need to keep synchronized, making sure to add, modify and delete users in both.

Although it is clearly your own business, I suggest to take a look at fully using WordPress as your userdatabase. I do that on linklaunder.com (which is not active at the moment, unfortunately), where I use a few plugins to ensure a double-opt-in system where users actively agree to the disclaimer, privacy policy, etc. This is through the use of the plugin “Register Plus”.

It is very easy to use a bit of php-code in your template files, to use WordPress to process user-level, and provide individual user data to logged in users.

Just my suggestion, let me know if you need some help, should you choose to go that direction.

Thank you for visiting, and leaving a comment! :-)

Reply

Ruth March 16, 2010 at 04:17

I am integrating a wordpress blog to my website and have created other tables in my wordpress database with individual user data. Is it possible to provide this information when the user logs in with their wordpress username and password?

Reply

myWordPress.com March 16, 2010 at 05:33

Hi Ruth

It sure is. I do not know how you store the data in the other tables, but I suspect you have their userid or login as reference in the other table?

Then it is “just” a matter of looking up the extra data referencing their $user_id, and display their information.

I suggest you use the built-in functionality in WordPress to let the users log in, and then have a piece of script similar to:


[php]
<?php
$user = wp_get_current_user();
$userid=$user->ID;

//user is logged in, $user->ID will be their ID, etc..
if ($userid<>'') {
$nicename=$user->user_nicename;
$registered=$user->user_registered;
echo "<h3>Welcome <strong>$nicename</strong></h3>";
echo "<p>Registered on: $registered</p>";
}

else

{
echo "<p>You are not logged in.</p>";
}

?>
[/php]

I have above code in a separate page-template in my theme.

In above code example you can add a lookup for their extra data if they are logged in.

I hope that it what you were looking for? If not, let me know, and I’ll see what I can do.

Reply

Ruth April 27, 2010 at 06:58

Thank you very much for posting this script, this is exactly what I was looking to do, and was able to incorporate it successfully into my code :)

Reply

Marius Patrascu April 23, 2010 at 05:07

Hello! this is the only thing close to what I need so thank you very much for using the time to write it!

I have an free script, me and some friends developed, and I wanna ask you, it it posible to build an external user system based on Wordpress use system?

Let’s say you have /root script and /root/u wordpress.

Can I loggin user in Wordpress and call user data in script? Like session, name, chack if it’s legged ?

Thank you very much for your time answer this!

Reply

Marius Patrascu April 23, 2010 at 05:08

I’m very sorry for my english, I hope you understant even with my mistakes.

Reply

Sal May 20, 2010 at 16:28

Thank you for posting this script it has helped out alot. One question though…

I am using this dynamically, grabbing the users username from the headers which has been authenticated from a different source. I’m looking for a script that will automatically add the user as a subscriber if they are not already in the DB. Anyone have a script that will accomplish that?

Reply

Leave a Comment

PRIVACY POLICY: Your privacy is important to us. We will never sell or rent your email address and you can unsubscribe at any time.

Previous post:

Next post: