在mycred中的转移点上添加密码验证

时间:2019-01-30 10:06:58

标签: php

当用户使用其akun密码(wp帐户自行密码)将其点转移到mycred插件WordPress上的其他帐户时,我尝试添加验证密码。我有代码,在(code 1中,我可以进行传输,但是密码无法检查代码2中是否为真。我可以进行传输,只是显示处理过程,但没有任何反应。 mycred版本1.7.9.8附加组件主动传输

code 1仍然无法传输,但是没有检查密码是否正确 code 2不会发生

//code 1
/**
 * Step 1 : Insert Message Field
 * @version 1.0
 */

add_action( 'mycred_transfer_form_to', 'mycred_pro_transfer_message_field' );

function mycred_pro_transfer_message_field() {
 ?>
<input type="text" style="display:none;" value="" />

<label>Confirm with your password</label>

<input type="password" name="pwd" id="mycred-user-pwd" autocomplete="off" 

value="" placeholder="required" />

<?php

}

/**
 * Step 2 : Verify Password
 * @version 1.0.1
 */

add_action( 'mycred_transfer_ready', 'mycred_pro_verify_transfer_pwd', 1, 4 );

function mycred_pro_verify_transfer_pwd( $post, $prefs, $transfer_addon, $type 
) {

    // If the password is empty
    if ( $post['pwd'] == '' )
        die( json_encode( 'Please enter your password!' ) );

    // Get the senders user object
    $sender = wp_get_current_user();

    // Let WordPress check if the provided password is correct
    if ( ! wp_check_password( $post['pwd'], $sender->user_pass, $sender->ID ) )
        die( json_encode( 'Incorrect Password' ) );

}


//code 2
/**
 * Step 1 : Insert Message Field
 * @version 1.0
 */

add_action( 'mycred_transfer_form_to', 'mycred_pro_transfer_message_field' );

function mycred_pro_transfer_message_field() {

 ?>

<input type="text" style="display:none;" value="" />

<label>Confirm with your password</label>

<input type="password" name="pwd" id="mycred-user-pwd" autocomplete="off" 

value="" placeholder="required" />

<?php

}

add_action( 'mycred_transfer_ready', 'mycred_pro_verify_transfer_pwd', 1, 5 );

function mycred_pro_verify_transfer_pwd( $transaction_id, $post, $prefs, 

$transfer_addon, $type ) {

    // If the password is empty
    if ( $post['pwd'] == '' )
        die( json_encode( 'Please enter your password!' ) );

    // Get the senders user object
    $sender = wp_get_current_user();

    // Let WordPress check if the provided password is correct
    if ( ! wp_check_password( $post['pwd'], $sender->user_pass, $sender->ID ) )
        die( json_encode( 'Incorrect Password' ) );

}

0 个答案:

没有答案