第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

提交后從方法刷新當(dāng)前頁面

提交后從方法刷新當(dāng)前頁面

PHP
胡子哥哥 2021-05-05 10:19:32
好的,我是新來的PHP寫作者,但我被卡住了。我有以下代碼:    add_shortcode( 'mycred_take', 'mycred_pro_render_take_shortcode' );function mycred_pro_render_take_shortcode( $atts, $label = 'Give Away' ) {    extract( shortcode_atts( array(        'user_id' => '',        'confirm' => '',        'amount'  => '',        'unique'  => 0,        'ref'     => 'mycred_take',        'entry'   => '%plural% lose',        'ctype'   => 'mycred_default'    ), $atts ) );    if ( ! is_user_logged_in() || ! function_exists( 'mycred' ) ) return '';    if ( $user_id == '' )        $user_id = get_current_user_id();    // Load essentials    $user_id = absint( $user_id );    $mycred = mycred( $ctype );    // User is excluded = has no balance    if ( $mycred->exclude_user( $user_id ) ) return '';    // Unique check    if ( $unique == 1 && $mycred->has_entry( $ref, 0, $user_id, '', $ctype ) ) return '';    $balance = $mycred->get_users_balance( $user_id, $ctype );    $output = '';    // If button was pushed    if ( isset( $_POST['mycred-take-points-token'] ) && wp_verify_nonce( $_POST['mycred-take-points-token'], 'mycred-deduct-points' . $ref . $ctype ) ) {        // Deduct        $mycred->add_creds(            $ref,            $user_id,            0 - $amount,            $entry        );        // Update balance        $balance = $balance - $amount;    }    // Too low balance    if ( $balance < $amount ) return '';    return $output . '<form action=""  method="post" id="mycred-take-shortcode' . $ref . $ctype . '"><input type="hidden" name="mycred-take-points-token" value="' . wp_create_nonce( 'mycred-deduct-points' . $ref . $ctype ) . '" /><input type="submit"  class="button"  value="' . $label . '" /></form>';}這是一個Wordpress簡碼。我想要在表單提交和數(shù)據(jù)庫更新后刷新頁面。由于此代碼當(dāng)前關(guān)閉且頁面未更新(如果我手動刷新頁面,則數(shù)據(jù)庫已更新,并且會顯示更改)。我嘗試了onSubmit =“ window.location.reload()”,action =“”代碼,但沒有用。
查看完整描述

2 回答

?
尚方寶劍之說

TA貢獻1788條經(jīng)驗 獲得超4個贊

請嘗試用下面的代碼替換您的代碼。


add_action("init","start_ob_start_cb");

function start_ob_start_cb()

{

     ob_start();

}


add_shortcode( 'mycred_take', 'mycred_pro_render_take_shortcode' );

function mycred_pro_render_take_shortcode( $atts, $label = 'Give Away' ) {


    extract( shortcode_atts( array(

        'user_id' => '',

        'confirm' => '',

        'amount'  => '',

        'unique'  => 0,

        'ref'     => 'mycred_take',

        'entry'   => '%plural% lose',

        'ctype'   => 'mycred_default'

    ), $atts ) );


    if ( ! is_user_logged_in() || ! function_exists( 'mycred' ) ) return '';


    if ( $user_id == '' )

        $user_id = get_current_user_id();


    // Load essentials

    $user_id = absint( $user_id );

    $mycred = mycred( $ctype );


    // User is excluded = has no balance

    if ( $mycred->exclude_user( $user_id ) ) return '';


    // Unique check

    if ( $unique == 1 && $mycred->has_entry( $ref, 0, $user_id, '', $ctype ) ) return '';


    $balance = $mycred->get_users_balance( $user_id, $ctype );


    $output = '';


    // If button was pushed

    if ( isset( $_POST['mycred-take-points-token'] ) && wp_verify_nonce( $_POST['mycred-take-points-token'], 'mycred-deduct-points' . $ref . $ctype ) ) {


        // Deduct

        $mycred->add_creds(

            $ref,

            $user_id,

            0 - $amount,

            $entry

        );


        // Update balance

        $balance = $balance - $amount;

wp_redirect(get_permalink()); die();

    }


    // Too low balance

    if ( $balance < $amount ) return '';


    return $output . '<form action=""  method="post" id="mycred-take-shortcode' . $ref . $ctype . '"><input type="hidden" name="mycred-take-points-token" value="' . wp_create_nonce( 'mycred-deduct-points' . $ref . $ctype ) . '" /><input type="submit"  class="button"  value="' . $label . '" /></form>';

}


查看完整回答
反對 回復(fù) 2021-05-28
  • 2 回答
  • 0 關(guān)注
  • 278 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號