[wp-hackers] Pluggables: wp_login -> Causing Fatal Errors

DD32 wordpress at dd32.id.au
Mon Aug 20 06:01:14 GMT 2007


On Mon, 20 Aug 2007 15:47:41 +1000, Curt Woodard <clwoodard at gmail.com>
wrote:

> When I'm trying to override the wp_login() function, WP can't start
> the plug-in... I'm rather baffled by this.

The problem is that when you ACTIVATE the plugin, wp_login DOES exist(ie.
plugables has allready been loaded).
But when the plugin is LOADED (after activation) then its loaded BEFORE
plugables, so wp_login is NOT defined when your plugin is parsed.

The fix is to wrap your plugable functions in a conditional wrapper too:

$smf_path = '/Path/To/SMF/';

require ($smf_path.'smf_api.php');

if( ! function_exists('wp_login') ){
function wp_login($username, $password, $already_md5 = false)
{
	global $wpdb, $error, $smf_user_info;

	$username = sanitize_user($username);
	if(!smf_authenticateUser())
	{
		smf_setLoginCookie(3600, addslashes($username), $password, false);
		smf_loadSession();
		smf_authenticateUser();
	}
	else
		smf_authenticateUser();
	
//... Actual code from pluggable.php's wp_login() here
}}

You'll probably have to do that to anyother plugable functions you want to
override too.

D
-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


More information about the wp-hackers mailing list