‘Send User Notification’ breaks when creating user
-
I’m seeing a problem with WP 4.6.1.
1) Admin creates a new user
2) checks “Send User Notification”.Expected: User receives an email.
Actual: No email sent/received.3) Turn off User Registration Aide.
repeat steps 1 & 2
Actual: user receives an email.
-
You can use this code until I release an update if you like. Around line 319 or so of classes/ura-email-class.php is the ura_new_user_notification function. After the function line there is the $options = get_option and then an if statement
if( is_int( $user_id ) ){. Insert a line space after the $options = get_option line then copy and past the following code over the $options = line and that should do it. So just paste this code over the$options = get_option( 'csds_userRegAide_Options' );line and insert a space after it and before theif( is_int( $user_id ) ){line. I want to update a few more things while I am at it so it may be a little more time before it is publicly released. Thanks for the input!global $screen; $screen = get_current_screen(); $options = get_option( 'csds_userRegAide_Options' ); if( !empty( $screen ) ){ if( $screen->id == 'user' ){ $user = new WP_User( $user_id ); $user_email = $user->user_email; $caps = get_user_meta( $user->ID, 'wp_capabilities', true ); $roles = array_keys( ( array )$caps ); $message = __( 'Hi, You\'ve been invited to join \'%1$s\' at %2$s with the role of %3$s. Please click the following link to confirm the invite: %4$s' ); wp_mail( $user_email, sprintf( __( '[%s] Joining confirmation' ), wp_specialchars_decode( get_option( 'blogname' ) ) ), sprintf( $message, get_option( 'blogname' ), home_url(), wp_specialchars_decode( translate_user_role( $roles[0] ) ), home_url( "/newbloguser/$newuser_key/" ) ) ); $redirect = add_query_arg( array('update' => 'add'), 'user-new.php' ); } }Cool. Thanks for the quick fix!
Forgot to add one thing for the key, not that it matters though, doesn’t seem to do anything.
global $screen; $screen = get_current_screen(); $options = get_option( 'csds_userRegAide_Options' ); if( !empty( $screen ) ){ if( $screen->id == 'user' ){ $user = new WP_User( $user_id ); $user_email = $user->user_email; $newuser_key = substr( md5( $user_id ), 0, 5 ); $caps = get_user_meta( $user->ID, 'wp_capabilities', true ); $roles = array_keys( ( array )$caps ); add_option( 'new_user_' . $newuser_key, array( 'user_id' => $user_id, 'email' => $user->user_email, 'role' => $roles[0] ) ); $message = __( 'Hi, You\'ve been invited to join \'%1$s\' at %2$s with the role of %3$s. Please click the following link to confirm the invite: %4$s' ); wp_mail( $user_email, sprintf( __( '[%s] Joining confirmation' ), wp_specialchars_decode( get_option( 'blogname' ) ) ), sprintf( $message, get_option( 'blogname' ), home_url(), wp_specialchars_decode( translate_user_role( $roles[0] ) ), home_url( "/newbloguser/$newuser_key/" ) ) ); $redirect = add_query_arg( array('update' => 'add'), 'user-new.php' ); } }Forgot to add the key, not that it matters though, doesn’t seem to do anything but just in case here is the modified code to be put in the same place.
global $screen; $screen = get_current_screen(); $options = get_option( 'csds_userRegAide_Options' ); if( !empty( $screen ) ){ if( $screen->id == 'user' ){ $user = new WP_User( $user_id ); $user_email = $user->user_email; $newuser_key = substr( md5( $user_id ), 0, 5 ); $caps = get_user_meta( $user->ID, 'wp_capabilities', true ); $roles = array_keys( ( array )$caps ); add_option( 'new_user_' . $newuser_key, array( 'user_id' => $user_id, 'email' => $user->user_email, 'role' => $roles[0] ) ); $message = __( 'Hi, You\'ve been invited to join \'%1$s\' at %2$s with the role of %3$s. Please click the following link to confirm the invite: %4$s' ); wp_mail( $user_email, sprintf( __( '[%s] Joining confirmation' ), wp_specialchars_decode( get_option( 'blogname' ) ) ), sprintf( $message, get_option( 'blogname' ), home_url(), wp_specialchars_decode( translate_user_role( $roles[0] ) ), home_url( "/newbloguser/$newuser_key/" ) ) ); $redirect = add_query_arg( array('update' => 'add'), 'user-new.php' ); } }
The topic ‘‘Send User Notification’ breaks when creating user’ is closed to new replies.