Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I modified the default Wordpress registration page to include a role and also payment fields. I am adding a Gold Member feature the my website, which requires payment.

I'd like it that after this user makes a payment and it is approved, he gets redirected back to the home page. I'm using the registration_errors filter to achieve this. This is not working, the user is instead redirected back to the wp-login page with a successful message on top.

Additionally, the wp_update_user function is not working either; the user is added to the db with the default role - Subscriber. How do I pass the user_id in here? Or, should I do this in another place.

function process_payment($errors, $sanitized_user_login, $user_email) {

if ( $errors->get_error_code() ) return $errors;

global $tran;

if($tran->Process()) {
    $approved = $tran->authcode;
    add_filter('registration_redirect', 'gold_login_redirect');
            wp_update_user( array ('ID' => $user_id, 'role' => 'gold_member') ) ;

} else {
    $errors->add( 'fidelipay_response', __('<strong>Declined</strong>:'. $tran->result . '<br/>' . $tran->error . '<br/>' . $tran->cvv2_result . '<br/>' ,'mysite.com') );
        if($tran->curlerror) {
            $errors->add( 'fidelipay_response', __('<strong>Reason</strong>:' . $tran->curlerror, 'mysite.com'));   
            return $errors; 
        }
        return $errors;                                                         
}
  return $errors;
}

add_filter('registration_errors', 'process_payment', 10, 3);

function gold_login_redirect() {
     return home_url('?role=gold_member');
}       
share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You can use wp_redirect function (Codex) at any point where you want to redirect the user:

wp_redirect( home_url() ); exit;
share|improve this answer
    
Thanks, the redirection worked, but the user didn't get entered into the db. –  MF1 Apr 17 '13 at 0:50
    
@MF1 here's what the doc says: To create a new user, use wp_insert_user() instead. –  dalbaeb Apr 17 '13 at 4:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.