← All changes
|
admin/advanced-settings/includes/fields/automatically-generate-password.php
+34
-2
3.9.9
→
4.0.3
View file →
| @@ -1,9 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | +// Exit if accessed directly | |
| 4 | +if ( ! defined( 'ABSPATH' ) ) exit; | |
| 5 | + | |
| 3 | 6 | $wppb_general_settings = get_option( 'wppb_general_settings' ); |
| 4 | 7 | |
| 5 | -if ( isset( $wppb_general_settings ) && $wppb_general_settings['emailConfirmation'] == 'yes' ) { | |
| 8 | +if ( isset( $wppb_general_settings['emailConfirmation'] ) && $wppb_general_settings['emailConfirmation'] == 'yes' ) { | |
| 6 | 9 | add_filter( 'wppb_register_user_email_message_with_admin_approval', 'wppb_toolbox_ec_generate_password', 20, 5 ); |
| 7 | 10 | add_filter( 'wppb_register_user_email_message_without_admin_approval', 'wppb_toolbox_ec_generate_password', 20, 5 ); |
| 8 | 11 | } |
| 9 | 12 | |
| @@ -26,8 +29,9 @@ | ||
| 26 | 29 | } |
| 27 | 30 | |
| 28 | 31 | add_filter( 'wppb_build_userdata', 'wppb_toolbox_generate_password', 20, 2 ); |
| 29 | 32 | function wppb_toolbox_generate_password( $userdata, $global_request ) { |
| 33 | + | |
| 30 | 34 | if ( $global_request['action'] == 'register' ) { |
| 31 | 35 | $userdata['user_pass'] = wp_generate_password(); |
| 32 | 36 | |
| 33 | 37 | return $userdata; |
| @@ -35,8 +39,15 @@ | ||
| 35 | 39 | |
| 36 | 40 | return $userdata; |
| 37 | 41 | } |
| 38 | 42 | |
| 43 | +add_filter( 'pms_stripe_wppb_password', 'wppb_toolbox_generate_password_stripe_wppb_checkout' ); | |
| 44 | +function wppb_toolbox_generate_password_stripe_wppb_checkout( $password ){ | |
| 45 | + | |
| 46 | + return wp_generate_password(); | |
| 47 | + | |
| 48 | +} | |
| 49 | + | |
| 39 | 50 | function wppb_toolbox_ec_generate_password( $content, $email, $password, $user_message_subject, $context ) { |
| 40 | 51 | if ( empty( $email ) ) return $content; |
| 41 | 52 | |
| 42 | 53 | $user = get_user_by( 'email', $email ); |
| @@ -46,8 +57,29 @@ | ||
| 46 | 57 | $password = wp_generate_password(); |
| 47 | 58 | |
| 48 | 59 | wp_set_password( $password, $user->ID ); |
| 49 | 60 | |
| 50 | - $content = str_replace( 'Your selected password at signup', $password, $content ); | |
| 61 | + $content = str_replace( __( 'Your selected password at signup', 'profile-builder' ), $password, $content ); | |
| 51 | 62 | |
| 52 | 63 | return $content; |
| 64 | +} | |
| 65 | + | |
| 66 | +// Replace Password in User Approved Email | |
| 67 | +add_filter( 'wppb_new_user_status_message_approved', 'wppb_toolbox_admin_approval_generate_password', 20, 5 ); | |
| 68 | +function wppb_toolbox_admin_approval_generate_password( $content, $user_info, $status, $user_message_from, $context ){ | |
| 69 | + | |
| 70 | + if( empty( $user_info->user_email ) ) | |
| 71 | + return $content; | |
| 72 | + | |
| 73 | + $user = get_user_by( 'email', $user_info->user_email ); | |
| 74 | + | |
| 75 | + if ( $user === false ) return $content; | |
| 76 | + | |
| 77 | + $password = wp_generate_password(); | |
| 78 | + | |
| 79 | + wp_set_password( $password, $user->ID ); | |
| 80 | + | |
| 81 | + $content = str_replace( __( 'Your selected password at signup', 'profile-builder' ), $password, $content ); | |
| 82 | + | |
| 83 | + return $content; | |
| 84 | + | |
| 53 | 85 | } |