Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Add extra user registration fields
- function czystespalanie__registration_fields() {
- # Get and set any values already sent
- $first_name = ( isset( $_POST['first_name'] ) ) ? $_POST['first_name'] : '';
- $last_name = ( isset( $_POST['last_name'] ) ) ? $_POST['last_name'] : '';
- $tel = ( isset( $_POST['tel'] ) ) ? $_POST['tel'] : '';
- # Simple spam bots and crawlers protection system
- $a = mt_rand( 1, 9 );
- $b = mt_rand( 1, 9 );
- if( mt_rand( 0, 1 ) === 1 ) {
- $sum = $a + $b;
- $sign = " + ";
- } elseif ( ( $a - $b ) === 0 ) {
- $sum = ++$a - $b;
- $sign = " - ";
- } else {
- $sum = $a - $b;
- $sign = " - ";
- }
- ## Hash sum before send with POST
- $_pre_captcha = md5 ( $sum );
- ?>
- <h4><?php _e( '*) Profile information', 'czystespalanie' ); ?></h4>
- <hr style="margin-bottom: 5px;"/>
- <p>
- <label for="first_name"><?php _e( 'First name', 'czystespalanie' ) ?></label>
- <input type="text" name="first_name" id="first_name" class="input" value="<?php echo esc_attr( stripslashes( $first_name ) ); ?>" required>
- </p>
- <p>
- <label for="last_name"><?php _e( 'Surname', 'czystespalanie' ) ?></label>
- <input type="text" name="last_name" id="last_name" class="input" value="<?php echo esc_attr( stripslashes( $last_name ) ); ?>" required>
- </p>
- <p>
- <label for="tel"><?php _e( 'Telephon:', 'czystespalanie' ) ?></label>
- <input type="tel" name="tel" id="tel" class="input" value="<?php echo esc_attr( stripslashes( $tel ) ); ?>" required>
- </p>
- <p><h4><?php _e( 'Anti-spam protection', 'czystespalanie' ); ?> <img class="anti-spam-shield" src="<?php echo get_template_directory_uri() . '/inc/images/anti-spam-protection.png'; ?>"></h4>
- <hr style="margin-bottom: 5px;"/>
- <label for="captcha" class="col-sm-4 control-label">
- <?php _e( 'Solve the equation:', 'czystespalanie' ); echo ' ' . $a . $sign . $b; ?> = ?
- </label>
- <input type="hidden" name="czystespalanie__pre_captcha" value="<?php echo esc_attr( $_pre_captcha ); ?>">
- <input type="text" name="czystespalanie_captcha" class="form-control" id="captcha">
- </p>
- <p style="margin-bottom: 5px;"><small><?php _e( '*) No additional profile details are required. You can complete them later in the dashboard.', 'czystespalanie' ); ?></small></p>
- <hr/>
- <?php
- }
- add_action( 'register_form', 'czystespalanie__registration_fields' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement