Skip to content

Instantly share code, notes, and snippets.

@dparker1005
Last active October 4, 2023 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dparker1005/a2285ab30e6e9aeacdcf3eae7ca9967c to your computer and use it in GitHub Desktop.
Save dparker1005/a2285ab30e6e9aeacdcf3eae7ca9967c to your computer and use it in GitHub Desktop.
Modify memberships that are given to users via Zapier. As written, this will change the billing amount shown to $10/year.
<?php
// Copy from below here...
/**
* Modify memberships that are given to users via Zapier.
* As written, this will change the billing amount shown to $10/year.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmproza_change_level( $level, $user_id, $old_level_status, $cancel_level ) {
if ( empty( $_REQUEST['pmpro_zapier_webhook'] ) ) {
return $level;
}
$custom_level = array(
'user_id' => $user_id,
'membership_id' => $level,
'code_id' => '',
'initial_payment' => 10,
'billing_amount' => 10,
'cycle_number' => 1,
'cycle_period' => 'Year',
'billing_limit' => 0,
'trial_amount' => 0,
'trial_limit' => 0,
'startdate' => current_time( 'mysql' ),
'enddate' => 'NULL'
);
return $custom_level;
}
add_filter( 'pmpro_change_level', 'my_pmproza_change_level', 10, 4 );
@sc0ttkclark
Copy link

Line 34 should be add_filter

@dparker1005
Copy link
Author

Line 34 should be add_filter

Fixed, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment