Advertisement
ccc279

my_add_user_cap_for_ticket

Mar 29th, 2022
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. add_action(
  2. 'AHEE__EE_Transaction_Processor__update_transaction_and_registrations_after_checkout_or_payment',
  3. 'my_add_user_cap_for_ticket',
  4. 10,
  5. 2
  6. );
  7.  
  8. function my_add_user_cap_for_ticket(
  9. $transaction,
  10. $update_params
  11. ) {
  12. if($transaction->status_ID() != 'TCM') {
  13. return;
  14. }
  15. $registrations = $transaction->registrations();
  16. foreach($registrations as $registration) {
  17. if($registration instanceof EE_Registration) {
  18. if($registration->get('TKT_ID') == 10) { // swap in your ticket ID here - This is for Early Bird Regular Membership
  19. $user = new WP_User(get_current_user_id());
  20. if( $user instanceof WP_User ) {
  21. $user->add_cap('foo'); // swap in your capability here
  22. }
  23. return;
  24. }
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement