亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

從動作開始而不刷新頁面

從動作開始而不刷新頁面

PHP
江戶川亂折騰 2021-05-18 13:10:12
好的,我有一個Wordpress網站,這是一個簡碼。基本上,這將更新數據庫并刷新當前頁面。但是我想要這個短代碼的另一個版本,它不會重新加載頁面。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>';}我想確保單擊按鈕時,僅當手動重新加載時才應重新加載頁面。我嘗試了簡單的POST,但沒有辦法提出解決方案。
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 164 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號