2015-11-06 60 views
0

我想在用戶註冊後重定向頁面我創建了兩個單選按鈕paynow並稍後在用戶註冊中支付我想在用戶單擊paynow用戶時重定向paynow用戶應註冊並重定向到自定義的網址,如果用戶選擇付費後的用戶進行註冊,併發送自定義URL用戶對這裏未來的支付是我用如何在用戶註冊後根據單選按鈕重定向

$myemail=$_POST['email']; 
     $first_name="firstname"; 
     $last_name="lastname"; 


    echo "<script>window.location.href='https://www.payumoney.com/?firstname=$first_name&last_name=$last_name'&email=$myemail'</script>"; 


    $to="[email protected]"; 
    $message = " 
    Please payus for registering account https://www.payumoney.com/?firstname=$first_name&last_name=$last_name'&email=$email' 
    "; 

    // To send HTML mail, the Content-type header must be set 
    $headers = 'MIME-Version: 1.0' . "\r\n"; 
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 

    // Additional headers 
    $headers .= 'To: madu<[email protected]>' . "\r\n"; 
    $headers .= 'From: madu<[email protected]>' . "\r\n"; 


    // Mail it 
    mail($to, $subject, $message, $headers); 

    } 

    } 
    add_filter('registration_redirect', 'wpse_19692_registration_redirect'); 


Radio buttons 
add_action('register_form', 'myplugin_register_form'); 
function myplugin_register_form() { 

    $first_name = (! empty($_POST['first_name'])) ? trim($_POST['first_name']) : ''; 

     ?> 
     <p> 
      <input type="radio" name="paystatus" id="paystatus" value="paynow">Pay Now<br> 
      <input type="radio" name="paystatus" id="paystatus" value="paylater">Pay Later 
     </p> 
     <?php 
    } 

    //2. Add validation. In this case, we make sure first_name is required. 
    add_filter('registration_errors', 'myplugin_registration_errors', 10, 3); 
    function myplugin_registration_errors($errors, $sanitized_user_login, $user_email) { 

     if (empty($_POST['first_name']) || ! empty($_POST['first_name']) && trim($_POST['first_name']) == '') { 
      $errors->add('first_name_error', __('<strong>ERROR</strong>: You must include a first name.', 'mydomain')); 
     } 

     return $errors; 
    } 

    //3. Finally, save our extra registration user meta. 
    add_action('user_register', 'myplugin_user_register'); 
    function myplugin_user_register($user_id) { 
     if (! empty($_POST['paystatus'])) { 
      $checkme= update_user_meta($user_id, 'paystatus', trim($_POST['paystatus'])); 
     } 


    } 

?> 

回答

0

您可將通過JavaScript取決於你的電臺的$ _POST值的用戶代碼:

// example radio name: "payment_time" 
// redirect to this url if value equals to "pay_now" 
if(isset($_POST['payment_time']) && $_POST['payment_time'] == 'pay_now'): 
?> 
    <script type="text/javascript"> 
     window.location.href = "http://url1.com"; 
    </script> 
<?php elseif(isset($_POST['payment_time']) && $_POST['payment_time'] == 'pay_later'): ?> 
    <script type="text/javascript"> 
     window.location.href = "http://url2.com"; 
    </script> 
<?php 
endif; 

與前端,創建一個表單與電臺:

<input type="radio" id="pay_now" name="payment_time" value="pay_now"><label for="pay_now"> Pay now</label> 
<input type="radio" id="pay_later" name="payment_time" value="pay_later"><label for="pay_later"> Pay later</label> 
+0

它不工作我加入WordPress的註冊字段我想爲 – maddog

+0

重定向所以,請把你的整個代碼兩個單選按鈕。無線電錶格和所有的處理代碼。確保你分開每個代碼塊,以便更好的可讀性。我還剛剛看到,您將收音機命名爲「paystatus」...收音機的名稱將是$ _POST數組中的關鍵名稱,就像我的示例中那樣。 – xphan