Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. unction registration_form( $name, $fname, $email, $password, $familyname, $username, $password, $gender) {
  2.  
  3. echo '
  4. <div class="login-form">
  5. <form action="' . get_site_url() . '/sign-up" method="post">
  6. <div class="form-group">
  7. <input type="text" name="name" placeholder="Name" value="' . ( isset( $_POST['name'] ) ? $name : null ) . '">
  8. </div>
  9.  
  10. <div class="form-group">
  11. <input type="text" name="fname" placeholder="Father Name" value="' . ( isset( $_POST['fname']) ? $fname : null ) . '">
  12. </div>
  13.  
  14. <div class="form-group">
  15. <input type="text" name="familyname" placeholder="Family Name" value="' . ( isset( $_POST['familyname']) ? $familyname : null ) . '">
  16. </div>
  17.  
  18. <div class="form-group">
  19. <input type="text" name="email" placeholder="Email" value="' . ( isset( $_POST['email']) ? $email : null ) . '">
  20. </div>
  21.  
  22. <div class="form-group">
  23. <input type="text" name="username" placeholder="Username" value="' . ( isset( $_POST['username']) ? $username : null ) . '">
  24. </div>
  25.  
  26. <div class="form-group">
  27. <input type="password" name="password" placeholder="Password" value="' . ( isset( $_POST['password'] ) ? $password : null ) . '">
  28. </div>
  29.  
  30. <div class="form-group">
  31. <label for="nickname">Gender</label>
  32. <div><input type="radio" name="gender" value="Male"> Male</div>
  33. <div><input type="radio" name="gender" value="Female"> Female</div>
  34. </div>
  35.  
  36. <input type="submit" name="submit" value="Register"/>
  37.  
  38. <div class="form-group"><br>
  39. Already have account with us <a href="'.get_site_url().'/log-in" title="" class="reg" id="">Login Here</a>
  40. </div>
  41.  
  42. </form>
  43. </div>
  44. ';
  45. }
  46.  
  47. function complete_registration() {
  48. global $name, $fname, $password, $familyname, $username, $password, $gender;
  49. if ( 1 > count( $reg_errors->get_error_messages() ) ) {
  50. $userdata = array(
  51. 'user_login' => $username,
  52. 'user_email' => $email,
  53. 'user_pass' => $password,
  54. 'user_name' => $name,
  55. 'family_name' => $familyname,
  56. 'father_name' => $fname,
  57. 'gender' => $gender
  58. );
  59. $user = wp_insert_user( $userdata );
  60. echo 'Registration complete. Goto <a href="' . get_site_url() . '/wp-login.php">login page</a>.';
  61. }
  62.  
  63. function custom_registration_function() {
  64. if ( isset($_POST['submit'] ) ) {
  65. // sanitize user form input
  66. $username = sanitize_user( $_POST['username'] );
  67. $password = esc_attr( $_POST['password'] );
  68. $email = sanitize_email( $_POST['email'] );
  69. $name = esc_url( $_POST['name'] );
  70. $fname = sanitize_text_field( $_POST['fname'] );
  71. $familyname = sanitize_text_field( $_POST['familyname'] );
  72. $gender = sanitize_text_field( $_POST['gender'] );
  73.  
  74. // call @function complete_registration to create the user
  75. // only when no WP_error is found
  76. complete_registration(
  77. $username,
  78. $password,
  79. $email,
  80. $name,
  81. $fname,
  82. $familyname,
  83. $gender
  84. );
  85. } else {
  86. registration_form(
  87. $username,
  88. $password,
  89. $email,
  90. $name,
  91. $fname,
  92. $familyname,
  93. $gender
  94. );
  95. }
  96.  
  97. }
  98.  
  99. // Register a new shortcode: [cr_custom_registration]
  100. add_shortcode( 'cr_custom_registration', 'custom_registration_shortcode' );
  101.  
  102. // The callback function that will replace [book]
  103. function custom_registration_shortcode() {
  104. ob_start();
  105. custom_registration_function();
  106. return ob_get_clean();
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement