Advertisement
Guest User

form-login-register

a guest
Apr 27th, 2023
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.91 KB | None | 0 0
  1. add_action( 'thim_form_register_widget', 'thim_form_register_widget', 10, 3 );
  2. function thim_form_register_widget( $captcha, $term, $redirect_to = 'account' ) { ?>
  3.     <form id="registerForm" class="<?php if ( get_theme_mod( 'thim_auto_login', true ) ) {
  4.         echo 'auto_login';
  5.     } ?>" name="registerformpopup"
  6.           action="<?php echo esc_url( site_url( 'wp-login.php?action=register', 'login_post' ) ); ?>"
  7.           method="post" novalidate="novalidate">
  8.  
  9.         <?php wp_nonce_field( 'ajax_register_nonce', 'register_security' ); ?>
  10.  
  11.         <p>
  12.             <input placeholder="<?php esc_attr_e( 'Username', 'eduma' ); ?>"
  13.                    type="text" name="user_login" class="input required"/>
  14.         </p>
  15.  
  16.         <p>
  17.             <input placeholder="<?php esc_attr_e( 'Email', 'eduma' ); ?>"
  18.                    type="email" name="user_email" class="input required"/>
  19.         </p>
  20.  
  21.         <?php if ( get_theme_mod( 'thim_auto_login', true ) ) { ?>
  22.             <p>
  23.                 <input placeholder="<?php esc_attr_e( 'Password', 'eduma' ); ?>"
  24.                        type="password" name="password" class="input required"/>
  25.             </p>
  26.             <p>
  27.                 <input
  28.                     placeholder="<?php esc_attr_e( 'Repeat Password', 'eduma' ); ?>"
  29.                     type="password" name="repeat_password"
  30.                     class="input required"/>
  31.             </p>
  32.         <?php } ?>
  33.  
  34.         <?php
  35.         if ( is_multisite() && function_exists( 'gglcptch_login_display' ) ) {
  36.             gglcptch_login_display();
  37.         }
  38.  
  39.         do_action( 'register_form' );
  40.         ?>
  41.  
  42.         <p class="thim-login-captcha"><div class="g-recaptcha" data-sitekey="6LdrCq8lAAAAADCwvzpIjKhs6JmC7ZqdeVBV2ytn" required></div></p>
  43.  
  44.         <?php
  45.         if(empty($_POST['g-recaptcha-response'] ) ) {
  46.             echo 'Please complete the reCAPTCHA';
  47.             return;
  48.         }
  49.         if ($captcha == 'yes') {
  50.             $recaptcha_secret = 'secret';
  51.             if (isset($_POST['g-recaptcha-response'] ) ) {
  52.                 $response = $_POST['g-recaptcha-response'];
  53.             } else {
  54.                 echo 'reCAPTCHA is not completed';
  55.                 return false;
  56.             }
  57.             $remote_ip = $_SERVER['REMOTE_ADDR'];
  58.             $url = "https://www.google.com/recaptcha/api/siteverify?secret=$recaptcha_secret&response=$response&remoteip=$remote_ip";
  59.             $curl = curl_init();
  60.  
  61.             curl_setopt_array($curl, array(
  62.                 CURLOPT_RETURNTRANSFER => 1,
  63.                 CURLOPT_URL => $url,
  64.                 CURLOPT_SSL_VERIFYPEER => false // need to disable SSL verification on some server setups
  65.             ));
  66.  
  67.             $result = curl_exec($curl);
  68.             curl_close($curl);
  69.  
  70.             $result_obj = json_decode($result);
  71.             if ($captcha == 'yes' && ! $result_obj->success) {
  72.                 echo 'reCAPTCHA verification failed';
  73.                 return;
  74.             }
  75.         } else {
  76.  
  77.         }
  78.         ?>
  79.  
  80.         <?php
  81.         if ( $term ):
  82.             $target = ( isset( $term['is_external'] ) && ! empty( $term['is_external'] ) ) ? '_blank' : '_self';
  83.             $rel = ( isset( $term['nofollow'] ) && ! empty( $term['nofollow'] ) ) ? 'nofollow' : 'dofollow';
  84.             ?>
  85.             <p>
  86.                 <input type="checkbox" class="required" name="term" id="termFormFieldPopup">
  87.                 <label
  88.                     for="termFormField"><?php printf( __( 'I accept the <a href="%s" target="%s" rel="%s">Terms of Service</a>', 'eduma' ), esc_url( $term['url'] ), $target, $rel ); ?></label>
  89.             </p>
  90.         <?php endif; ?>
  91.         <?php
  92.         if ( $redirect_to == 'current' ) {
  93.             $register_redirect = esc_url( thim_eduma_get_current_url() );
  94.         } else {
  95.             $register_redirect = get_theme_mod( 'thim_register_redirect', false );
  96.             if ( empty( $register_redirect ) ) {
  97.                 $register_redirect = add_query_arg( 'result', 'registered', thim_get_login_page_url() );
  98.             }
  99.         }
  100.         ?>
  101.         <!--<input type="hidden" name="redirect_to"
  102.                value="<?php echo ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : $register_redirect; ?>"/>
  103.         <input type="hidden" name="modify_user_notification" value="1">
  104.         <input type="hidden" name="eduma_register_user">-->
  105.  
  106.  
  107.         <?php do_action( 'signup_hidden_fields', 'create-another-site' ); ?>
  108.         <p class="submit">
  109.             <input type="submit" name="wp-submit" class="button button-primary button-large"
  110.                    value="<?php echo esc_attr_x( 'Sign up', 'Login popup form', 'eduma' ); ?>"/>
  111.         </p>
  112.     </form>
  113. <?php }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement