-
-
Save Pebblo/8e657cffab1ddd1bd16451fe567c02eb to your computer and use it in GitHub Desktop.
If you use BuddyPress as the 'Registration Page URL' within Event Espresso -> Reg Form -> User Integration Settings this allows you to automatically log the user in when they create an account and redirect them back to the checkout to continue the registration.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php //Please do not include the opening PHP tag if you already have one | |
//Function to allow you to use BuddyPress registration as for site registrations during the EE Checkout | |
//and then redirect them back to the checkout. | |
function tw_ee_bp_redirect($user_id) { | |
$checkout = EE_Registry::instance()->SSN->checkout(); | |
if( $checkout instanceof EE_Checkout ) { | |
$user = get_user_by( 'id', $user_id); | |
if( $user ) { | |
wp_set_current_user( $user->ID, $user->user_login ); | |
wp_set_auth_cookie( $user->ID ); | |
do_action( 'wp_login', $user->user_login ); | |
wp_safe_redirect( $checkout->reg_page_base_url ); | |
exit; | |
} | |
} | |
} | |
add_action('bp_core_signup_user', 'tw_ee_bp_redirect', 100, 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment