Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unction registration_form( $name, $fname, $email, $password, $familyname, $username, $password, $gender) {
- echo '
- <div class="login-form">
- <form action="' . get_site_url() . '/sign-up" method="post">
- <div class="form-group">
- <input type="text" name="name" placeholder="Name" value="' . ( isset( $_POST['name'] ) ? $name : null ) . '">
- </div>
- <div class="form-group">
- <input type="text" name="fname" placeholder="Father Name" value="' . ( isset( $_POST['fname']) ? $fname : null ) . '">
- </div>
- <div class="form-group">
- <input type="text" name="familyname" placeholder="Family Name" value="' . ( isset( $_POST['familyname']) ? $familyname : null ) . '">
- </div>
- <div class="form-group">
- <input type="text" name="email" placeholder="Email" value="' . ( isset( $_POST['email']) ? $email : null ) . '">
- </div>
- <div class="form-group">
- <input type="text" name="username" placeholder="Username" value="' . ( isset( $_POST['username']) ? $username : null ) . '">
- </div>
- <div class="form-group">
- <input type="password" name="password" placeholder="Password" value="' . ( isset( $_POST['password'] ) ? $password : null ) . '">
- </div>
- <div class="form-group">
- <label for="nickname">Gender</label>
- <div><input type="radio" name="gender" value="Male"> Male</div>
- <div><input type="radio" name="gender" value="Female"> Female</div>
- </div>
- <input type="submit" name="submit" value="Register"/>
- <div class="form-group"><br>
- Already have account with us <a href="'.get_site_url().'/log-in" title="" class="reg" id="">Login Here</a>
- </div>
- </form>
- </div>
- ';
- }
- function complete_registration() {
- global $name, $fname, $password, $familyname, $username, $password, $gender;
- if ( 1 > count( $reg_errors->get_error_messages() ) ) {
- $userdata = array(
- 'user_login' => $username,
- 'user_email' => $email,
- 'user_pass' => $password,
- 'user_name' => $name,
- 'family_name' => $familyname,
- 'father_name' => $fname,
- 'gender' => $gender
- );
- $user = wp_insert_user( $userdata );
- echo 'Registration complete. Goto <a href="' . get_site_url() . '/wp-login.php">login page</a>.';
- }
- function custom_registration_function() {
- if ( isset($_POST['submit'] ) ) {
- // sanitize user form input
- $username = sanitize_user( $_POST['username'] );
- $password = esc_attr( $_POST['password'] );
- $email = sanitize_email( $_POST['email'] );
- $name = esc_url( $_POST['name'] );
- $fname = sanitize_text_field( $_POST['fname'] );
- $familyname = sanitize_text_field( $_POST['familyname'] );
- $gender = sanitize_text_field( $_POST['gender'] );
- // call @function complete_registration to create the user
- // only when no WP_error is found
- complete_registration(
- $username,
- $password,
- $email,
- $name,
- $fname,
- $familyname,
- $gender
- );
- } else {
- registration_form(
- $username,
- $password,
- $email,
- $name,
- $fname,
- $familyname,
- $gender
- );
- }
- }
- // Register a new shortcode: [cr_custom_registration]
- add_shortcode( 'cr_custom_registration', 'custom_registration_shortcode' );
- // The callback function that will replace [book]
- function custom_registration_shortcode() {
- ob_start();
- custom_registration_function();
- return ob_get_clean();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement