View Full Version : Help with WordPress, somebody who knows it well!
11-22-2006, 05:11 AM
I've got a site which has an existing custom made user management thingy in it. All PHP and MySQL. It uses sessions.
When the administrator logs in, the home page has a new, small menu with some administrative things he can do to update the site. Also just custom made stuff.
But now they want WordPress. The owner of the site wants everything baby simple as well.
So basically all I want to do is add a new entry in this custom admin menu, for "edit blog" or whatever. And this will go into the WordPress admin panel and already BE logged in to WP.
In other words, I don't want the admin to have to log in once to the main site, and then have to log in again for WordPress. I want it all to be together. I can't have WP's user manager take over, because of all the custom stuff.
As far as I can see, WP uses a cookie to track who's logged in. So I'm wondering if there is a way to have it auto-login to WP's admin panel when he clicks the "edit blog" button after already being logged in to the main site?
In sum, I need to log him into WP through code and no user action. And redirect him to the WP admin panel.
11-22-2006, 05:29 AM
Here's my two cents:
First, when you are logged into WordPress, do a var_dump of the $_COOKIE array to see what's in there.
Now, when you log in to your main site, create new values in the $_COOKIE array that emulate what you just saw when you did a var_dump...
Would that work?
Edit: By the way, in case you are interested, I know WordPress very well, as I just recently created a demo CMS that uses WordPress as its backend. I stripped away all of the blog stuff, and the resulting CMS works quite well. And I think my modified WordPress backend interface is very intuitive for my clients who don;t know anything about the Internet (much more so than say Mambo or Joomla, if you've heard of those)...And the front end of my CMS can use any design template -- it just so happens that I'm only using a slightly modified version of the default WordPress template for my demo...
11-22-2006, 06:16 AM
Thanks for the quick reply.
Running a var_dump returns "NULL".
But using print_r($COOKIE) reveals this:
Array ( [wordpressuser_2b56cb6d3b6927e340f474ab862a613b] => admin [wordpresspass_2b56cb6d3b6927e340f474ab862a613b] => 8b2e945d83f5ebd4b0483aac5d8a53c1 [dbx-postmeta] => grabit=0-,1-,2-,3-,4-,5-,6-&advancedstuff=0 ,1-,2 ,3-,4 ,5- )
What do you make of that? Looks like some MD5's going on. Shouldn't be a big problem, but I don't know what the numbers are after "wordpressuser_XYZ?"
Autogenerated timestamp or something?
Does that make sense to you? I've been searching around the net for how to log in through code, not finding much yet.
11-22-2006, 06:54 AM
Here's a tool that you might find useful (that I actually wrote for myself): http://www.mediamogulsweb.com/client/function_search.php.
It searches for a function in ALL of the WordPress files. If it finds the function, it returns the file name that it is in. It is currently set to search files on my server, but I should have the same standard functions as you. The tool is a big time saver when you start hunting for functions and dont know where they are (for example, functions that regulate logging in).
As far as your problem is concerned, this is what I was saying:
$_COOKIE['wordpressuser_2b56cb6d3b6927e340f474ab862a613b'] = "admin";
$_COOKIE['wordpresspass_2b56cb6d3b6927e340f474ab862a613b'] = "8b2e945d83f5ebd4b0483aac5d8a53c1";
$_COOKIE['dbx-postmeta'] = "grabit=0-,1-,2-,3-,4-,5-,6-&advancedstuff=0 ,1-,2 ,3-,4 ,5-";Set those elements of the COOKIE array when you log into your main site. Then, with some simple redirection I'd imagine, you can forward the user from any page to the WP backend. See if it works, and allows you to access the WP backend without logging in. (It might not work, I'm just guessing).
Edit: Or you might use some application of setcookie (http://us2.php.net/manual/en/function.setcookie.php) to assign values to your COOKIE array, using the key/value pairs from above..
If that works, then you dont need to know what those alphanumeric codes (in the COOKIE element keys) mean. But the values of the array elements are username, encoded password, and meta data -- all of which I think can be found in either the wp_users and/or wp_usermeta tables in your database.
If the above doesn;t work, try using my tool and dig around for the functions that regulate loggin in. Start with wp_login.php, and then just start searching for functions.
BTW, my tool only accepts the function name....It doesn;t need to be prepended with "function" or appended with (argument1,argument2,etc.)....
Good luck with this, and let me know how it goes.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.