I’m creating a plugin. I’m receiving the following error (WP 3.5):
Fatal error: Call to undefined function wp_set_password() in \path\to\plugin.php on line 18
Line 18 consists of simply:
wp_set_password( 'newpass', $user_id );
This is located in the main plugin file, and all other code has been commented out in order to try and seclude this error. I have no idea why it’s showing up as undefined.
Am I missing something here?:
http://codex.wordpress.org/Function_Reference/wp_set_password
Thanks
1 Answer
When your plugin loads, pluggable functions aren’t loaded yet, in fact a lot of stuff is not loaded yet, this what actions are for. Hook your function to an action, like plugins_loaded
or init
, when the WP environment is loaded and initialized:
add_action( 'init', 'wpa80246_init' );
function wpa80246_init(){
wp_set_password( 'newpass', $user_id );
}