Support » Plugin: Buddypress Force Password Change » All User Force

Viewing 6 replies - 1 through 6 (of 6 total)
  • I was wondering as well if there would be an option to force users to change their password on first login. Is that possible? With a hook or filter?
    Thanks,
    Sascha

    Ok, solved this by adding this on creation of the user to their user meta:

    // force password change on first login
    update_usermeta( $user_id, 'force_password_change', 'yes' );

    When the first login, then they have to enter a new password.
    Maybe it helps somebody 🙂
    Sascha

    Sascha –

    To which file did you add this code?

    Thx,
    Jeff

    Hi Jeff,

    I create users by using a plugin, so that function is hooked into that.
    Otherwise this wordpress hook might come in useful, but I have not tested it:

    http://codex.wordpress.org/Plugin_API/Action_Reference/user_register

    add_action( 'user_register', 'myplugin_registration_save', 10, 1 );
    
    function myplugin_registration_save( $user_id ) {
    
        // force password change on first login
        update_usermeta( $user_id, 'force_password_change', 'yes' );
    
    }

    That code would go into your functions.php or a custom plugin.
    Obviously you could adjust the code above to only force users of a certain role to change their password etc. All you need to do is just check for the users capabilities and then update their meta or not.
    S

    Sascha –

    Thanks for all this. Simple but helpful.
    Are you using your own plugin for creating users or from the WP repos’y or premium?
    I am looking for a way to create new users but, haven’t found the right one yet. I also need a way for users to change their own password and haven’t found that yet either.

    Have a good one.
    jeff

    Hi Jeff,

    all depends what you want to do. I use BuddyPress which I think let users change their passwords under “Settings” on the front end. Also depends if your users have access to backend or not. Then they can just change it there.

    Creating users: well, users can just register on my site, but they need a registration code to do that. If you want to create users manually then you can use the backend.
    As said, all depends what and how you want to do things.
    S

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘All User Force’ is closed to new replies.