Wasif Khalil
Wasif Khalil

Reputation: 2247

How to run custom code(hooks) after user signup on Paid Memberships Pro

i want to execute a custom code after user signup on Paid Memberships PRO and this looks like a solution

http://www.paidmembershipspro.com/hooks-filters/

"pmpro_after_checkout" looks exactly what i am looking for, but how do i execute it? where to write the custom code??? should i write this function in my theme's function.php file??

will it be a right approach if i write a new function in functions.php for example in the sample code here "http://www.paidmembershipspro.com/hook/pmpro_after_checkout/" i write a new function

function my_pmpro_after_checkout($user_id){
    //my custom code here
}

and call it in this location wp-content/paid-memberships-pro/preheaders/checkout.php line# 929 where another one is already called:

 //hook
 do_action("pmpro_after_checkout", $user_id);

and can i call my own function like this?

do_action("my_pmpro_after_checkout", $user_id);

i apologize if i didnt understand it... any help would be appreciated

Upvotes: 2

Views: 3542

Answers (1)

Domain
Domain

Reputation: 11808

Add this code in your theme functions.php or create a plugin and add there in plugins file:

add_action("pmpro_after_checkout", "update_user_meta_after_upgrade", 10 ,1 );

function update_user_meta_after_upgrade( $user_id ){
    // Get level details 
    $membership_level_details   = pmpro_getMembershipLevelsForUser($user_id);
    $level_id           = $membership_level_details[0]->ID;
// perform action according to the level    
return;
    }

Upvotes: 5

Related Questions