Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@sc0ttkclark sc0ttkclark commented Jun 18, 2021

Line 34 should be add_filter

@dparker1005

This comment has been minimized.

Copy link
Owner Author

@dparker1005 dparker1005 commented Jun 21, 2021

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