Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

migrated from webmasters.stackexchange.com Nov 16 '12 at 1:39

This question came from our site for pro webmasters.

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer
    
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 Nov 16 '12 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). –  Simon Blackbourn Nov 16 '12 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 Nov 17 '12 at 4:45

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 );
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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