Advertisement
Guest User

Untitled

a guest
Apr 14th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.17 KB | None | 0 0
  1. //Gravity Forms Username
  2.     add_filter( 'gform_username', 'auto_username', 10, 4 );
  3.     function auto_username( $username, $feed, $form, $entry ) {
  4.  
  5.         $username = strtolower( rgar( $entry, '2.3' ) . rgar( $entry, '2.6' ) );
  6.        
  7.         if ( empty( $username ) ) {
  8.             return $username;
  9.         }
  10.        
  11.         if ( ! function_exists( 'username_exists' ) ) {
  12.             require_once( ABSPATH . WPINC . '/registration.php' );
  13.         }
  14.  
  15.         if ( username_exists( $username ) ) {
  16.             $i = 2;
  17.             while ( username_exists( $username . $i ) ) {
  18.                 $i++;
  19.             }
  20.             $username = $username . $i;
  21.         };
  22.        
  23.         return $username;
  24.     }
  25.  
  26. // Redefine user notification function
  27.     if ( !function_exists('wp_new_user_notification') ) {
  28.         function wp_new_user_notification( $user_id, $plaintext_pass = '' ) {
  29.             $user = new WP_User($user_id);
  30.  
  31.             $user_login = stripslashes($user->user_login);
  32.             $user_email = stripslashes($user->user_email);
  33.             $user_firstname = stripslashes($user->user_firstname);
  34.  
  35.             if ( empty($plaintext_pass) )
  36.                 return;
  37.  
  38.             //$message  = __('Hi there,') . "\r\n\r\n";
  39.             $message .= sprintf(__("Beste %s,"), ucfirst($user_firstname)) . "\r\n\r\n";
  40.             $message .= sprintf(__("Bedankt voor het aanmaken van een account op %s!"), get_option('blogname')) . "\r\n\r\n";
  41.             $message .= sprintf(__('Je gebruikersnaam is: %s'), $user_email) . "\r\n";
  42.             $message .= sprintf(__('Je wachtwoord is automatisch gegenereerd: %s'), $plaintext_pass) . "\r\n\r\n";
  43.             $message .= sprintf(__('Je kunt je account hier raadplegen om je bestellingen te bekijken en je wachtwoord te wijzigen: https://www.30kiloafvallen.nl/my-account/.'), get_option('admin_email')) . "\r\n\r\n";
  44.             $message .= __('Tot snel!');
  45.  
  46.             wp_mail($user_email, sprintf(__('[%s] Uw Gebruikersnaam en Wachtwoord'), get_option('blogname')), $message);
  47.  
  48.         }
  49.     }
  50.  
  51. //Auto login after registration
  52.     function auto_login_new_user( $user_id ) {
  53.             wp_set_current_user($user_id);
  54.             wp_set_auth_cookie($user_id);
  55.                 // You can change home_url() to the specific URL,such as
  56.             //wp_redirect( 'http://www.wpcoke.com' );
  57.             wp_redirect( 'https://www.30kiloafvallen.nl/product-categorie/afslanken/' );
  58.             exit;
  59.         }
  60.         add_action( 'user_register', 'auto_login_new_user' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement