function choice_update_password(){
global $wpdb;
$old_password=$_REQUEST['old_password'];
$N_password=$_REQUEST['new_password'];
$user = wp_get_current_user();
$encrypt_pass= $user->data->user_pass;
if ($user && wp_check_password( $old_password, $user->data->user_pass, $user->ID) ) {
wp_set_password($N_password, $user->ID);
$url="profile";
$view_profile=site_url($url);
echo json_encode(array("type"=>"success","data"=>"","url"=> $view_profile));
die();
}else{
echo json_encode(array("type"=>"failure","data"=>""));
die();
}
}
和ajax部分
function mail_prop_update($clsfrm) {
var $form = jQuery($clsfrm),$dataType = "json";
$form.on('click', 'input[type=submit]', function(e) {
var $elements = $form.find('input:not(input[type="submit"],input[type="button"],input[type="hidden"],input[type="file"],input[type="text"].not-required),textarea#message');
var $bool = $elements.validate();
var email = $form.find('input[type="email"]').val();
var action = $form.find('input[name="action"]').val();
if ($bool) {
ajax_submit($form, $elements, $dataType);
}
alert(e.responseText.type);
e.preventDefault();
});
}