User
function delete_img(img_delete, image = 'image') {
jQuery('#upload'+img_delete).val('');
jQuery('#upload_img'+img_delete).val('');
jQuery('#img_view'+img_delete).attr('src','https://auto-djelovi.me/wp-content/plugins/wp-user/assets/images/'+image+'.png');
jQuery('#img_delete_'+img_delete).hide();
console.log(img_delete);
}
var wpuser = {wpuser_ajax_url:'https://auto-djelovi.me/wp-admin/admin-ajax.php',wp_user_security_reCaptcha_enable:0,login_redirect:''};
var $ = jQuery.noConflict();
$(".step_btn_prev").click(function () {
var prevTab = $(this).attr('data-prev');
var currentTab = $(this).attr( 'data-current' );
$('#step_count_' + prevTab).trigger('click');
$('#step_count_' + prevTab).removeClass().addClass( 'badge bg-blue' );
$('#step_count_' + currentTab).removeClass().addClass( 'badge bg-gray' );
});
$(".step_btn_next").click(function () {
if($("#google_form1711677897833").valid()){
var nextTab = $(this).attr( 'data-next' );
$('#step_count_' + nextTab).trigger( 'click' );
var currentTab = $(this).attr( 'data-current' );
$('#step_count_' + currentTab).removeClass().addClass( 'badge bg-green' );
$('#step_count_' + currentTab).parent().removeClass( 'wpuser_step_disable' );
$('#step_count_' + nextTab).removeClass().addClass( 'badge bg-blue' );
$('#step_count_' + nextTab).parent().removeClass( 'wpuser_step_disable' );
}
//$('#step_'+prevTab).tab('show');
});
$("#wpuser_register1711677897833").click(function () {
//if( false == $("#google_form1711677897833")[0].checkValidity() ) {
// $("input:focus:invalid").css("border-color","red");
// return true;
// }
if ( $("#google_form1711677897833").valid() ) {
if (wpuser.wp_user_security_reCaptcha_enable == 1) {
if (grecaptcha.getResponse() == '') {
$('#wpuser_error_register1711677897833').html("Please verify Captcha");
$('#wpuser_errordiv_register1711677897833').removeClass().addClass('alert alert-dismissible alert-warning');
$('#wpuser_errordiv_register1711677897833').show();
return false;
}
}
$.ajax({
url: wpuser.wpuser_ajax_url + '?action=wpuser_register_action',
data: $("#google_form1711677897833").serialize(),
error: function (data) {
},
success: function (data) {
var parsed = $.parseJSON(data);
$('#wpuser_error_register1711677897833').html('');
$(".form-control").removeClass("wpuser_invalid");
$(".wpuser_error").removeClass("wpuser_view_error");
$('.wpuser_error').hide();
$('#wpuser_error_register1711677897833').html(parsed.message);
$('#wpuser_errordiv_register1711677897833').removeClass().addClass('alert alert-dismissible alert-' + parsed.status);
if (parsed.status == 'success') {
$("#google_form1711677897833")[0].reset();
}
if (parsed.status == 'warning' && typeof( parsed.error ) !== "undefined" && ( parsed.error.length != 0 )) {
$.each(parsed.error, function (key, value) {
if (( typeof( value.message ) !== "undefined" )) {
$('#error' + key).html(value.message);
$('#error' + key).addClass('wpuser_view_error');
$('#' + key).addClass('wpuser_invalid');
}
});
$('.wpuser_view_error').show();
if( typeof( parsed.error_in_forms ) !== "undefined" && ( parsed.error_in_forms.length != 0 ) ){
$.each(parsed.error_in_forms, function (key, value) {
$('#step_count_' + key).removeClass().addClass('badge bg-red');
});
}
}
if (parsed.message == 'Registration completed') {
window.location.reload(true);
}
$('#wpuser_errordiv_register1711677897833').show();
$("#loader_action").hide();
$('html, body').animate({
scrollTop: $('#wpuser_errordiv_register1711677897833').offset().top
}, 2000);
},
type: 'POST'
});
}
});
$("#wpuser_login1711677897833").click(function () {
$("#loader_action").show();
$.ajax({
url: wpuser.wpuser_ajax_url+'?action=wpuser_login_action',
data: $( "#wpuser_login_form1711677897833" ).serialize(),
error: function (data) {
},
success: function (data) {
var parsed = $.parseJSON(data);
$('#upuser_error1711677897833').html(parsed.message);
$('#wpuser_errordiv1711677897833').removeClass().addClass('alert alert-dismissible alert-' + parsed.status);
$('#wpuser_errordiv1711677897833').show();
if ( parsed.status == 'success' ) {
$("#wpuser_login_form1711677897833")[0].reset();
var redirectURL = ''
if ( !( redirectURL.length === 0 ) ) {
window.location.href = redirectURL;
}
else if ( wpuser.register_redirect.length != 0 ) {
window.location.href = wpuser.register_redirect;
}
else if ( wpuser.login_redirect == null || ( typeof( wpuser.login_redirect ) !== "undefined" && wpuser.login_redirect.length === 0 ) ) {
location.reload();
}
else {
window.location.href = wpuser.login_redirect;
}
}
$("#loader_action").hide();
},
type: 'POST'
});
});
$("#wpuser_login_resend_otp1711677897833").click(function () {
console.log('wpuser_login_resend_otp');
$( "#wpuser_login_otp1711677897833" ).trigger( "click" );
});
$("#wpuser_otp_password_div1711677897833").click(function () {
$( "#wpuser_otp_div1711677897833" ).show();
$("#wpuser_otp_1711677897833").hide();
$("#div_wp_user_password1711677897833").show();
$("#wpuser_otp_password_div1711677897833").hide();
});
$("#wpuser_login_otp1711677897833").click(function () {
console.log('wpuser_login_resend_otp111111111');
$("#loader_action").show();
$.ajax({
url: wpuser.wpuser_ajax_url+'?action=wpuser_login_otp_action',
data: $( "#wpuser_login_form1711677897833" ).serialize(),
error: function (data) {
},
success: function (data) {
var parsed = $.parseJSON(data);
$('#upuser_error1711677897833').html(parsed.message);
$('#wpuser_errordiv1711677897833').removeClass().addClass('alert alert-dismissible alert-' + parsed.status);
$('#wpuser_errordiv1711677897833').show();
if ( parsed.status == 'success' ) {
$("#div_wp_user_password1711677897833").hide();
$("#wpuser_otp_div1711677897833").hide();
$("#wpuser_otp_password_div1711677897833").show();
$("#wpuser_otp_1711677897833").show();
}
$("#loader_action").hide();
},
type: 'POST'
});
});
$("#wpuser_forgot1711677897833").click(function () {
$("#loader_action").show();
$.ajax({
url: wpuser.wpuser_ajax_url+'?action=wpuser_forgot_action',
data: $("#wpuser_forgot_form1711677897833").serialize(),
error: function (data) {
},
success: function (data) {
var parsed = $.parseJSON(data);
$('#upuser_error_forgot1711677897833').html(parsed.message);
$('#wpuser_errordiv_forgot1711677897833').removeClass().addClass('alert alert-dismissible alert-' + parsed.status);
if (parsed.status == 'success') {
$("#wpuser_forgot_form1711677897833")[0].reset();
}
$('#wpuser_errordiv_forgot1711677897833').show();
$("#loader_action").hide();
},
type: 'POST'
});
});
$("#wp_login_btn1711677897833").click(function () {
$('#wp_login1711677897833').modal();
var modal = $("#wp_login1711677897833"),
dialog = modal.find('.modal-dialog');
modal.css('display', 'block');
// Dividing by two centers the modal exactly, but dividing by three
// or four works better for larger screens.
dialog.css("margin-top", Math.max(0, ($(window).height() - dialog.height()) / 2));
});
$("#wp_user_profile_div_close").click(function () {
$("#wp_user_profile_div").hide();
});
$(function () {
var file_frame;
$(".additional-user-image").on("click", function (event) {
event.preventDefault();
// If the media frame already exists, reopen it.
if (file_frame) {
file_frame.open();
return;
}
// Create the media frame.
file_frame = wp.media.frames.file_frame = wp.media({
title: $(this).data("uploader_title"),
button: {
text: $(this).data("uploader_button_text"),
},
multiple: false
});
var current_id = this.id;
// When an image is selected, run a callback.
file_frame.on("select", function () {
// We set multiple to false so only get one image from the uploader
attachment = file_frame.state().get("selection").first().toJSON();
//$(".user_meta_image").val(attachment.url);
$("#img_" + current_id).val(attachment.url);
$("#user_meta_image_attachment_id").val(attachment.id);
// Do something with attachment.id and/or attachment.url here
});
// Finally, open the modal
file_frame.open();
});
});