Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Last active May 17, 2017 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pebblo/8e657cffab1ddd1bd16451fe567c02eb to your computer and use it in GitHub Desktop.
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.
<?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