Question

I'm working on buddypress custom subscription form.

At the moment accounts are created just after filling the membership form, it means, a lot of accounts are created without paying. We want to clean up this mess.

I'd like to move account to be created at the end of the payment step.

$anyerrors = $error->get_error_code();
if(is_wp_error($error) && !empty($anyerrors)) {
        $messages = $error->get_error_messages();
        $content .= '<p class="error" id="reg-error" style="display: block;">';
        $content .= implode('<br/>', $messages);
        $content .= '</p>';
        // Show the page so that it can display the errors
        $content = $this->output_registeruser( $content, $_POST );
    } else {
        $content = $this->output_paymentpage( $user_id );
        // everything seems fine (so far), so we have our queued user so let's
        // run the bp complete signup action
        do_action( 'bp_complete_signup' );
        // display the payment forms
        if(!defined('MEMBERSHIP_NOLOGINONREGISTRATION')) {
            if(!headers_sent()) {
                    wp_set_current_user($user_id);
                    wp_set_auth_cookie($user_id);
                    }
        }

$content = $this->output_paymentpage( $user_id ); this line is responsible for redirecting to PayPal.

do_action( 'bp_complete_signup' ); This one is for creating account.

I want to know if there is any way to get 'reply' with true/false from PayPal if payment is completed or not.

How to do it in proper way?

Thanks in advance, Adam

Was it helpful?

Solution

Use Paypal IPN. It will make a request with POST data about payment to a specified url with a payment status. You can create a user in that file if the payment is successful.

More info here: https://www.paypal.com/ipn

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top