m3hdigh 0 ارسال شده در اردیبهشت 98 گزارش بازنشر ارسال شده در اردیبهشت 98 سلام و وقت بخیر ، بنده یک قالب آماده خریداری کرده ام برای آموزش آنلاین LMS . یک سرویس ارسال sms هم از کاوه نگار باری احراز هویت خریداری کرده ام . ثبت نام و ورود در دوره ها با استفاده از یک پلاگین انجام میشه . که من در قسمت account اون رو به طور کل پاک کردم و تغییر دادم ( قسمت عضویت در سایت ) در حال حاضر یکسری مشکلات برای چک کردن اعضای ثبت نام شده دارم و همچنین فراموشی رمز عبور . ممنون میشم اگر کمکم کنید . صفحه عضویت <h2 class="registerFormTitle">ثبت نام</h2> <div class="AuthWithMobile"> <form action="#" method="post" id="AuthWithMobileForm"> <label>کد ارسال شده خود را وارد نمایید.</label> <input type="hidden" name="AuthCodeDefault" id="AuthCodeDefault"> <input type="text" class="isNumberic" name="AuthMobileCode" id="AuthMobileCode" placeholder="کد احراز هویت" maxlength="4"> <input type="submit" class="btn btn-default" id="SumbitAuthMobile" value="احراز هویت"> </form> </div> <form action="#" method="post" id="SignUpForm"> <div class="form-group"> <label for="register_first_name">نام</label> <input type="text" name="register_first_name" id="register_first_name" > </div> <div class="form-group"> <label for="register_last_name">نام خانوادگی</label> <input type="text" name="register_last_name" id="register_last_name" > </div> <div class="form-group"> <label for="register_mobile">شماره موبایل</label> <input type="text" name="register_mobile" class="isNumberic" id="register_mobile" maxlength="11"> </div> <div class="form-group"> <label for="register_first_name">کلمه عبور</label> <input type="password" name="register_password" id="register_password" > </div> <input type="submit" class="btn btn-default" id="SubmitRegisterForm" value="ثبت نام"> </form> javascript function AuthMobile(){ var ajaxurl = "/wp-admin/admin-ajax.php"; var register_mobile = jQuery("form#SignUpForm #register_mobile").val(); jQuery.ajax({ type: 'POST', dataType: 'json', url: ajaxurl, data: { 'action' : 'exir_danesh_Auth_With_Mobile', 'mobile' : register_mobile, }, success: function (data) { if (data.status !== 'true' ) { jQuery(".AuthWithMobile").show(); jQuery("#AuthCodeDefault").val(data.auth_code); return true; return true; }else{ alert("کلمه عبور وارد شده اشتباه می باشد."); } }, error: function (errorThrown) { } }); } jQuery(document).ready(function () { jQuery("#AuthWithMobileForm").submit(function (e) { e.preventDefault(); var auth_code = jQuery("#AuthMobileCode").val(); auth_code = + auth_code * 3781; var Current_auth_code = jQuery("#AuthCodeDefault").val(); if(auth_code.length < 4){ jQuery("form#AuthWithMobileForm #AuthWithMobileForm").css("border","1px solid #ff0035"); return false; } else{ jQuery("form#AuthWithMobileForm #AuthWithMobileForm").removeAttr("style"); } if(auth_code == Current_auth_code){ var ajaxurl = "/wp-admin/admin-ajax.php"; var register_first_name = jQuery("form#SignUpForm #register_first_name").val(); var register_last_name = jQuery("form#SignUpForm #register_last_name").val(); var register_mobile = jQuery("form#SignUpForm #register_mobile").val(); var register_password = jQuery("form#SignUpForm #register_password").val(); jQuery.ajax({ type: 'POST', dataType: 'json', url: ajaxurl, data: { 'action' : 'exir_danesh_SignUpWith_mobile', 'user_name' : register_mobile, 'user_password' : register_password , 'user_first_name' : register_first_name , 'user_last_name' : register_last_name , }, success: function (data) { if (data.status) { // $(".SignUpMobile#AlertAjax").hide(); // $("form#SignUpForm #SignUpBtn").val(data.message); window.location.reload(); }else{ window.location.reload(); } }, error: function (errorThrown) { window.location.reload(); } }); } else{ jQuery("form#AuthWithMobileForm #AuthWithMobileForm").css("border","1px solid #ff0035"); alert("error"); } }) jQuery("body .isNumberic").on("keypress keyup blur",function () { jQuery(this).val(jQuery(this).val().replace(/[^\d].+/, "")); if ((event.which < 48 || event.which > 57)) { event.preventDefault(); } if(jQuery(this).val() == ""){jQuery(this).val()} }); jQuery("form#SignUpForm").submit(function (e) { e.preventDefault(); var register_first_name = jQuery("form#SignUpForm #register_first_name").val(); var register_last_name = jQuery("form#SignUpForm #register_last_name").val(); var register_mobile = jQuery("form#SignUpForm #register_mobile").val(); var register_password = jQuery("form#SignUpForm #register_password").val(); if(register_first_name.length < 3){ jQuery("form#SignUpForm #register_first_name").css("border","1px solid #ff0035"); return false; } else{ jQuery("form#SignUpForm #register_first_name").removeAttr("style"); } if(register_last_name.length < 3){ jQuery("form#SignUpForm #register_last_name").css("border","1px solid #ff0035"); return false; } else{ jQuery("form#SignUpForm #register_last_name").removeAttr("style"); } if(register_mobile.length < 11){ jQuery("form#SignUpForm #register_mobile").css("border","1px solid #ff0035"); return false; } else{ jQuery("form#SignUpForm #register_mobile").removeAttr("style"); } if(register_password.length < 8){ jQuery("form#SignUpForm #register_password").css("border","1px solid #ff0035"); return false; } else{ jQuery("form#SignUpForm #register_password").removeAttr("style"); } if(AuthMobile()){ return true; } else{ return false; } }); }); sms.php <?php function CurlSend($request,$params,$result = false){ // Generate curl request $session = curl_init($request); // Tell curl to use HTTP POST curl_setopt ($session, CURLOPT_POST, true); // Tell curl that this is the body of the POST curl_setopt ($session, CURLOPT_POSTFIELDS, $params); // Tell curl not to return headers, but do return the response curl_setopt($session, CURLOPT_HEADER, false); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); // obtain response $response = curl_exec($session); curl_close($session); // print everything out if($result){ return true; } } add_action( 'wp_ajax_exir_danesh_Auth_With_Mobile', 'exir_danesh_Auth_With_Mobile' ); add_action( 'wp_ajax_nopriv_exir_danesh_Auth_With_Mobile', 'exir_danesh_Auth_With_Mobile' ); if( !function_exists('exir_danesh_Auth_With_Mobile') ): function exir_danesh_Auth_With_Mobile(){ $mobile = sanitize_text_field($_POST['mobile']); $message = rand(1000,9999); $apiCode = "*************************************************"; $request = 'https://api.kavenegar.com/v1/'.$apiCode.'/verify/lookup.json'; $params = array(); $params['receptor'] = $mobile; $params['token'] = $message; $params['template'] = "VerifyCode"; $send_auth = CurlSend($request,$params); $code = $message * 3781; print json_encode(array("status" => true, "auth_code" => $code)); exit(); } endif; ?> Function.php require_once get_template_directory().'/inc/ajaxcall.php'; require_once get_template_directory().'/inc/sms.php'; ajaxcall.php <?php //SignUp Mobile add_action( 'wp_ajax_exir_danesh_SignUpWith_mobile', 'exir_danesh_SignUpWith_mobile' ); add_action( 'wp_ajax_nopriv_exir_danesh_SignUpWith_mobile', 'exir_danesh_SignUpWith_mobile' ); if( !function_exists('exir_danesh_SignUpWith_mobile') ): function exir_danesh_SignUpWith_mobile(){ $user_name = sanitize_text_field($_POST['user_name']); $user_password = sanitize_text_field($_POST['user_password']); $user_first_name = sanitize_text_field($_POST['user_first_name']); $user_last_name = sanitize_text_field($_POST['user_last_name']); $user = wp_create_user($user_name,$user_password,""); update_user_meta($user,"first_name",$user_first_name); update_user_meta($user,"last_name",$user_last_name); $login = wp_signon(array("user_login" => $user_name,"user_password" => $user_password, "remember" => "true"),true); print json_encode(array('status'=>true,'message'=>"شما با موفقیت ثبت نام شدید لطفا منتظر بمانید...")); exit(); } endif; ?> نقل قول لینک به ارسال
پست های پیشنهاد شده
به گفتگو بپیوندید
هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .