Home › Forums › Plugin Support › Send password with activation email
Tagged: password activation
- This topic has 12 replies, 6 voices, and was last updated 9 years, 2 months ago by rrichardson24.
-
AuthorPosts
-
June 1, 2012 at 10:45 am #1508June 2, 2012 at 12:03 am #1514KhaledMember
Hello,
Sending password is only supported with registration email. Either WordPress or User Meta does not save plain text user password after completing registration. So we can only able to retrieve plain text password while registration.Thanks
June 2, 2012 at 12:16 am #1515mobiousdesignMemberthe pitfalls of trying to figure out new stuff at midnight! Kinda figured that out about 9am today…BUT, leads to another question…would it be possible to generate a new password on admin activation…to then send THAT password with the activation email? wp_generate_password again possibly?
June 2, 2012 at 12:26 am #1516KhaledMemberYes. It is possible. you can use “user_meta_user_activate” action hook. This hook accept $user_id parameter.
Thanks.
June 2, 2012 at 3:23 pm #1522mobiousdesignMemberOk, I’m getting closer…but my oop skills are non-existent,
so, if I update umEmailNotificationController userActivate to:
function userActivate( $userID ){
global $wpdb;
$user = new WP_User( $userID );
$new_pass = wp_generate_password(12, false);
$data = array(
'user_pass' => md5($new_pass),
'user_activation_key' => '',
);
$where = array(
'ID' => $user->ID,
);
update_user_meta( $user->ID, 'show_admin_bar_front', 'false' );
$wpdb->update($wpdb->users, $data, $where, array('%s', '%s'), array('%d'));
wp_cache_delete($user->ID, 'users');
wp_cache_delete($user->user_login, 'userlogins');
$user->password = $new_pass;
$this->_sendEmail( 'activation', $user );
}
It works great…BUT I’d prefer to use the hooks you’ve built instead…So if I want to remove your action and add my own:
remove_action( 'user_meta_user_activate', array( '$userMeta:umEmailNotificationController', 'userActivate' ));
is what I thought would do it…but your userActivate is still getting called…
add_action( 'user_meta_user_activate', 'user_meta_new_password');
function user_meta_new_password($userID){
global $wpdb;
$user = new WP_User( $userID );
$new_pass = wp_generate_password(12, false);
$data = array(
'user_pass' => md5($new_pass),
'user_activation_key' => '',
);
$where = array(
'ID' => $user->ID,
);
update_user_meta( $user->ID, 'show_admin_bar_front', 'false' );
$wpdb->update($wpdb->users, $data, $where, array('%s', '%s'), array('%d'));
wp_cache_delete($user->ID, 'users');
wp_cache_delete($user->user_login, 'userlogins');
$user->password = $new_pass;
//umEmailNotificationController::$this->_sendEmail( 'activation', $user );
}
I’ve commented out the last line because it throws an error…basically I haven’t written or messed with classes before, so no idea how to get in and out of them…any guidance would be great!
BTW, this is an AMAZING plugin!
- This reply was modified 12 years, 5 months ago by mobiousdesign.
- This reply was modified 12 years, 5 months ago by mobiousdesign.
June 3, 2012 at 1:38 am #1529KhaledMemberHello,
You can also follow this way:
remove_all_actions('user_meta_user_activate');add_action( 'user_meta_user_activate', 'user_meta_new_password' );
function user_meta_new_password($userID){
$user = new WP_User( $userID );
$newPass = wp_generate_password(12, false);
$user->password = $newPass;wp_update_user( array('ID' => $userID, 'user_pass' => $newPass ) );
update_user_option( $userID, 'default_password_nag', true, true );umEmailNotificationController::_sendEmail( 'activation', $user );
}
If you follow this way, you need to change two line for umEmailNotificationController. Line 100 and 107
From:
$userMeta->sendEmail( this->_prepareEmail( $mailData, $user ) );
To:
$userMeta->sendEmail( self::_prepareEmail( $mailData, $user ) );
Don’t worry for plugin upgrade. We’ll update those two line of code with next version 😉
Thanks.
June 3, 2012 at 2:27 am #1531mobiousdesignMemberWow…you seriously rock! Have another question…but I’ll start a new thread! Cheers!
August 31, 2012 at 11:33 pm #1957kimtanasichukMemberHi there,
I’m new to User Meta, but this functionality sounds important to my current problem. Can you walk me through the logic a bit?I have an excel file of Users that I want to import and my desired outcome is that I import all the users with meta variables, and then activate those users as a ‘batch’ so that all 300 are emailed their account info including their uniquely generated passwords.
How do I set this up in User Meta?
Thank you so much!
September 1, 2012 at 1:46 pm #1963KhaledMemberHi,
When you import new user by User Import tools of User Meta plugin, all user status will set to be “activated” automatically.
For sending them email with uniquely generated passwords, don’t include password field in your csv and there is a checkbox labeled ” Send email to new user.” Please check that checkbox before hit import button.
Thanks.
December 11, 2012 at 6:00 pm #2629idglabsMemberI try this modification in order to send to user the password after the administrator of the web site activated the user registration
but not work
I change from:Line 95: $userMeta->sendEmail( $this->_prepareEmail( $mailData, $user ) );
Line 110: //original $userMeta->sendEmail( self::_prepareEmail( $mailData, $user ) );
To:
$userMeta->sendEmail( self::_prepareEmail( $mailData, $user ) );But not work
any suggestion it’s welcomed…
User Meta Pro 1.1.3rc1thank you
December 12, 2012 at 8:41 pm #2640idglabsMembersome news?
March 29, 2015 at 12:49 am #6927eliteweblabsMemberI am seeking help on this as well. could you please identify where the code needs to go?
September 2, 2015 at 5:31 am #7574rrichardson24MemberAny update on this?
Geez it takes so long for questions to get answered – 3 years passed -
AuthorPosts
- You must be logged in to reply to this topic.