Advertisement
Guest User

Untitled

a guest
Jan 12th, 2016
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.50 KB | None | 0 0
  1. define('WP_DEBUG',true);
  2. define('dtni_REGISTRATION_INCLUDE_URL', plugin_dir_url(__FILE__).'includes/');
  3. ob_start();
  4.  
  5.  
  6. //add front end css and js
  7. function dtni_slider_trigger(){
  8. wp_enqueue_style('dtni_css_and_js', dtni_REGISTRATION_INCLUDE_URL."front-style.css");
  9. wp_register_script('dtni_css_and_js', dtni_REGISTRATION_INCLUDE_URL."font-script.js" );
  10. wp_enqueue_script('dtni_css_and_js');
  11. }
  12. add_action('wp_footer','dtni_slider_trigger');
  13.  
  14. // function to registration Shortcode
  15. function dtni_registration_shortcode( $atts ) {
  16. global $wpdb, $user_ID;
  17. $firstname='';
  18. $lastname='';
  19. $username='';
  20. $email='';
  21.  
  22. /* //if looged in rediret to home page
  23. if ( is_user_logged_in() ) {
  24. wp_redirect( get_option('home') );// redirect to home page
  25. exit;
  26. } */
  27.  
  28. if(sanitize_text_field( $_POST['com_submit']) != ''){
  29.  
  30. $keresztnév=sanitize_text_field( $_REQUEST['com_firstname'] );
  31. $családnév=sanitize_text_field( $_REQUEST['com_lastname'] );
  32.  
  33. $username = sanitize_text_field( $_REQUEST['com_username'] );
  34. $email = sanitize_text_field( $_REQUEST['com_email'] );
  35. $password = $wpdb->escape( sanitize_text_field( $_REQUEST['com_password']));
  36. $status = wp_create_user($username,$password,$email);
  37. $succress ='';
  38. $error_msg='';
  39.  
  40. if (is_wp_error($status)) {
  41. $error_msg = __('Username or Email already registered. Please try another one.','');
  42. }
  43. else{
  44. $user_id=$status;
  45. update_user_meta( $user_id,'first_name', $fullname);
  46. update_user_meta( $user_id,'last_name', $családnév);
  47.  
  48. $succress= __('Your are register successfully for this site.','');
  49.  
  50. $user_info=get_userdata( $user_id );
  51.  
  52. wp_mail($user_info->user_email, 'User first and last name', sprintf('Hi we have added your first name :-% and last name:- % to our site.',$_POST['fullname']));
  53.  
  54.  
  55. }
  56. }
  57.  
  58. ?>
  59.  
  60. <div class="digtalthinkersni-registration-form">
  61.  
  62. <?php if($error_msg!='') { ?><div class="error"><?php echo $error_msg; ?></div><?php } ?>
  63. <?php if($succress!='') { ?><div class="success"><?php echo $succress; ?></div><?php } ?>
  64.  
  65. <form name="form" id="registration" method="post">
  66. <div class="ftxt">
  67. <label><?php _e("Keresztnév: *",'');?></label>
  68. <input id="com_firstname" name="com_firstname" type="text" class="input" required value=<?php echo $keresztnév; ?> >
  69. </div><div class="ftxt">
  70. <label><?php _e("Családnév: *",'');?></label>
  71. <input id="com_fullname" name="com_lastname" type="text" class="input" required value=<?php echo $családnév; ?> >
  72. </div>
  73.  
  74. <div class="ftxt">
  75. <label><?php _e("Felhasználói név :*",'');?></label>
  76. <input id="com_username" name="com_username" type="text" class="input" required value=<?php echo $username; ?> >
  77. </div>
  78. <div class="ftxt">
  79. <label><?php _e("E-mail: *",'');?> </label>
  80. <input id="com_email" name="com_email" type="email" class="input" required value=<?php echo $email; ?> >
  81. </div>
  82. <div class="ftxt">
  83. <label><?php _e("Jelszó :*",'');?></label>
  84. <input id="password1" name="com_password" type="password" required class="input" />
  85. </div>
  86. <div class="ftxt">
  87.  
  88. <input id="password2" name="c_password" type="password" class="input" />
  89. <label><?php _e("Jelszó még egyszer: * ",'');?></label>
  90. </div>
  91. <div class="ftxt">
  92. <label>
  93.  
  94. <?php _e("Newsletter Signup : ",'');?>
  95. <input type="checkbox" name="mc4wp-subscribe" value="1" />
  96. </label>
  97. </div>
  98. <input type="hidden" name="action" id="action" value="hideme" />
  99.  
  100. <div class="fbtn"><input type="submit" name='com_submit' class="button" value="<?php _e("Regisztráció",'');?>"/> </div>
  101. </form>
  102. </div>
  103. <?php
  104. }
  105.  
  106.  
  107. //add registration shortcoode
  108. add_shortcode( 'digtialthinkers-registration-form', 'dtni_registration_shortcode' );
  109.  
  110. ?>
  111.  
  112. if ( !function_exists('wp_new_user_notification') ) :
  113. /**
  114. * Pluggable - Email login credentials to a newly-registered user
  115. *
  116. * A new user registration notification is also sent to admin email.
  117. *
  118. * @since 2.0.0
  119. *
  120. * @param int $user_id User ID.
  121. * @param string $plaintext_pass Optional. The user's plaintext password. Default empty.
  122. */
  123. function wp_new_user_notification($user_id, $plaintext_pass = ''){
  124.  
  125. $user = get_userdata($user_id);
  126.  
  127. // The blogname option is escaped with esc_html on the way into the database in sanitize_option
  128. // we want to reverse this for the plain text arena of emails.
  129. $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
  130.  
  131. $message = sprintf(__('New user registration on your site %s:'), $blogname) . "rnrn";
  132. $message .= sprintf(__('Username: %s'), $user->user_login) . "rnrn";
  133. $message .= sprintf(__('E-mail: %s'), $user->user_email) . "rn";
  134.  
  135. @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
  136.  
  137. if ( empty($plaintext_pass) )
  138. return;
  139.  
  140. $message = sprintf(__('Username: %s'), $user->user_login) . "rn";
  141. $message .= sprintf(__('Password: %s'), $plaintext_pass) . "rn";
  142. $message .= wp_login_url() . "rn";
  143.  
  144. wp_mail($user->user_email, sprintf(__('[%s] Your username and password'), $blogname), $message);
  145.  
  146. }
  147. endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement