Php 用户根据单选按钮wordpress注册后如何重定向

Php 用户根据单选按钮wordpress注册后如何重定向,php,wordpress,wordpress-theming,Php,Wordpress,Wordpress Theming,我尝试在用户注册后重定向页面我在用户注册中创建了两个单选按钮paynow和pay later我想在用户单击paynow时重定向用户应注册并重定向到自定义url,如果用户选择pay later,则用户应注册并发送自定义url给用户,以便将来付款这里是我使用的代码 $myemail=$_POST['email']; $first_name="firstname"; $last_name="lastname"; echo "<script&g

我尝试在用户注册后重定向页面我在用户注册中创建了两个单选按钮paynow和pay later我想在用户单击paynow时重定向用户应注册并重定向到自定义url,如果用户选择pay later,则用户应注册并发送自定义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="test@gmail.com";   
    $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<test@gmail.com>' . "\r\n";
    $headers .= 'From: madu<test@gmail.com>' . "\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'] ) );
        }


    }

?> 

您可以通过JavaScript重定向用户,具体取决于收音机的$\u 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>

它不工作,我在wordpress注册字段中添加了两个单选按钮,我想重定向,所以请发布您的全部代码。无线电表单和所有处理代码。确保将每个代码块分开,以使其可读性更好。我还看到,你把收音机命名为paystatus。。。收音机的名称将是$\u POST数组中的键名称,如我的示例中所示。