-
-
Save Pebblo/ccb58ca8b466b7a37bd39184ece1ab55 to your computer and use it in GitHub Desktop.
Add a new capability to WP User account after they complete a registration for a specific event. Event Espresso 4
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, except of course if you're starting with a blank file | |
add_action( | |
'AHEE__EE_Transaction_Processor__update_transaction_and_registrations_after_checkout_or_payment', | |
'my_add_user_cap_for_ticket', | |
10, | |
2 | |
); | |
function my_add_user_cap_for_ticket( | |
$transaction, | |
$update_params | |
) { | |
if($transaction->status_ID() != 'TCM') { | |
return; | |
} | |
$registrations = $transaction->registrations(); | |
foreach($registrations as $registration) { | |
if($registration instanceof EE_Registration) { | |
$TKT_ID = $registration->get('TKT_ID'); | |
if($TKT_ID == 166) { // swap in your ticket ID here - This is for Early Bird Regular Membership | |
$user = wp_get_current_user(); | |
if( $user instanceof WP_User ) { | |
write_log('add cap here'); | |
$user->add_cap('foo'); // swap in your capability here | |
} | |
return; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment