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


  • what action do you call this on? – Milo Jan 12 '13 at 1:39
  • I'm not calling it through an action. I originally had it placed inside of a function, but I received the error. So I placed it in the file all by itself and am still receiving the error. I've even manually defined the function (code here: wpseek.com/wp_set_password), but then I receive an error stating that wp_hash_password is undefined. – wesf90 Jan 12 '13 at 1:44
  • see my answer below – Milo Jan 12 '13 at 1:48

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 );
  • Makes sense now. That had crossed my mind, but I couldn't find anything to back the thought up online. Now that I know the entire pluggable file is not loaded until init, it should help with a lot of future problems as well :) Thanks – wesf90 Jan 12 '13 at 1:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.