-
Notifications
You must be signed in to change notification settings - Fork 2
/
rpr-new-user-notification.php
47 lines (44 loc) · 3 KB
/
rpr-new-user-notification.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
if ( function_exists( 'wp_new_user_notification' ) ) {
if ( $rpr_admin_menu instanceof RPR_Admin_Menu ) add_action( 'admin_notices', array( $rpr_admin_menu, 'rpr_new_user_notification_warning' ), 10, 0 );
}
// Called after user completes registration from wp-login.php
// Called after admin creates user from wp-admin/user-new.php
// Called after admin creates new site, which also creates new user from wp-admin/network/edit.php (MS)
// Called after admin creates user from wp-admin/network/edit.php (MS)
//
// Action: rpr_new_user 2 parameters ($user_id, $plaintext_pass). Should not generate output.
if ( !function_exists( 'wp_new_user_notification' ) ) {
/*.void.*/ function wp_new_user_notification( /*.int.*/ $user_id, $plaintext_pass = '' ) {
global $pagenow;
global $register_plus_redux;
//trigger_error( sprintf( __( 'Register Plus Redux DEBUG: wp_new_user_notification($user_id=%s, $plaintext_pass=%s) from %s', 'register-plus-redux' ), $user_id, $plaintext_pass, $pagenow ) );
if ( '1' === $register_plus_redux->rpr_get_option( 'user_set_password' ) && !empty( $_POST['pass1'] ) )
$plaintext_pass = stripslashes( (string) $_POST['pass1'] );
if ( 'user-new.php' === $pagenow && !empty( $_POST['pass1'] ) )
$plaintext_pass = stripslashes( (string) $_POST['pass1'] );
if ( '1' === $register_plus_redux->rpr_get_option( 'user_set_password' ) )
update_user_option( $user_id, 'default_password_nag', false, true ); // turn off the Password change nag.
do_action( 'rpr_new_user', $user_id, $plaintext_pass );
//TODO: Code now only forces users registering to verify email, may want to add settings to have admin created users verify email too
$verification_code = '';
$user_registering = 'wp-login.php' === $pagenow || $register_plus_redux->rpr_wp_modal_registration();
if ( $user_registering && '1' === $register_plus_redux->rpr_get_option( 'verify_user_email' ) ) {
$verification_code = wp_generate_password( 20, FALSE );
update_user_meta( $user_id, 'email_verification_code', $verification_code );
update_user_meta( $user_id, 'email_verification_sent', gmdate( 'Y-m-d H:i:s' ) );
$register_plus_redux->send_verification_mail( $user_id, $verification_code );
}
if ( ( $user_registering && '1' !== $register_plus_redux->rpr_get_option( 'disable_user_message_registered' ) ) ||
( ! $user_registering && '1' !== $register_plus_redux->rpr_get_option( 'disable_user_message_created' ) ) ) {
if ( '1' !== $register_plus_redux->rpr_get_option( 'verify_user_email' ) && '1' !== $register_plus_redux->rpr_get_option( 'verify_user_admin' ) ) {
$register_plus_redux->send_welcome_user_mail( $user_id, $plaintext_pass );
}
}
if ( ( $user_registering && '1' !== $register_plus_redux->rpr_get_option( 'disable_admin_message_registered' ) ) ||
( ! $user_registering && '1' !== $register_plus_redux->rpr_get_option( 'disable_admin_message_created' ) ) ) {
$register_plus_redux->send_admin_mail( $user_id, $plaintext_pass, $verification_code );
}
}
}
?>