[wp-hackers] Re: Pluggables: wp_login -> Causing Fatal Errors
Curt Woodard
clwoodard at gmail.com
Mon Aug 20 08:01:25 GMT 2007
Thanks for the tip, D!
I guess I hadn't really thought about that part, even though I've been
looking through pluggable.php and seeing that around each function...
Though, the syntax is:
if(!function_exists(<function name>)) :
function <function name> { }
endif;
For some reason, it wouldn't work the other way.
Anyhow, good news is: If you have an account in WordPress that has the
same username and password as that in SMF, you now log into both at
the same time! As long as both WordPress and SMF are on the same
server... heh. I had to fix some issues with smf_api, however, but
after doing that, it worked.
There is a function in smf_api.php that is nested and here is the fix
(if you're interested):
if(!function_exists('smf_cookie_url')):
function smf_cookie_url($local, $global)
{
global $smf_settings;
// Use PHP to parse the URL, hopefully it does its job.
$parsed_url = parse_url($smf_settings['forum_url']);
if (isset($parsed_url['port']))
$parsed_url['host'] .= ':' . $parsed_url['port'];
// Set the cookie to the forum's path only?
if (empty($parsed_url['path']) || !$local)
$parsed_url['path'] = '';
// This is probably very likely for apis and such, no?
if ($global)
{
// Try to figure out where to set the cookie; this can be confused, though.
if (preg_match('~(?:[^\.]+\.)?(.+)\z~i', $parsed_url['host'], $parts) == 1)
$parsed_url['host'] = '.' . $parts[1];
}
// If both options are off, just use no host and /.
elseif (!$local)
$parsed_url['host'] = '';
return $parsed_url;
}
endif;
Wrapping this function in an if...exists statement fixes an issue with
WordPress since it seems to run the wp_login function twice... I don't
know why, but it does.
Now to trick the login and logout of WordPress to use the SMF members
database instead of it's users/usermeta databases... and, of course,
set the WP cookies properly (or use the SMF cookies)... Slow but sure
progress!
Let's hope it can be done or all this pain will be for naught ;)
Thanks again for your help, guys! And for the links to the archives!
-Curt
More information about the wp-hackers
mailing list