2

Users on my website sign up through a form (Gravity form) and after they are manually approved they are sent a username (their email address) and a randomly generated password.

I would like these users to be forced to change their password when they first login, is this achievable?

I took a look at the thread Can I force a password change? but that doesn't resolve my issue.

2 Answers 2

3

I've put together a quick plugin at https://github.com/lumpysimon/wp-force-password-change in response to your question and a recent client request for exactly the same thing.

It adds a user meta field on registration, then checks for the presence of this when a user is logged in. If it's not there, they are redirected to the edit profile page and an admin notice is displayed. After they change their password the user meta field is removed.

3
  • Hi Simon, thanks that's pretty great. Now all I need is when a user changes their password and click "Update profile" I can choose to redirect them to a specific page.
    – rlsaj
    Commented Nov 16, 2012 at 22:38
  • hmmm... that's a tricky one. WordPress does a bunch of validation & checks when the edit profile page is submitted, & i don't think there's a way to redirect after those (i can't see a hook available to use). Commented Nov 16, 2012 at 23:58
  • Hi again Simon, in the end I hardcoded a button on the Update Profile page to say, "Back to <page>" which does the trick for what I need. Thanks again for your help.
    – rlsaj
    Commented Nov 17, 2012 at 4:45
9

WordPress has this already built in essentially. It's not clear how you are processing the form, but when you register the user, just call:

update_user_option( $user_id, 'default_password_nag', true, true );

Alternatively (if that's not possible?) you can use a hook:

add_action('user_register', 'wpse72788_password_nag');
function wpse72788_password_nag( $user_id ){
     update_user_option( $user_id, 'default_password_nag', true, true );
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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