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
function my_pmpro_after_change_membership_level_default_level($level_id, $user_id) | |
{ | |
//set this to the id of the level you want to give members when they cancel | |
$cancel_level_id = 1; | |
//if we see this global set, then another gist is planning to give the user their level back | |
global $pmpro_next_payment_timestamp; | |
if(!empty($pmpro_next_payment_timestamp)) | |
return; |
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
/* | |
* Add WP User Avatar from Register Helper field during checkout. | |
*/ | |
function my_updated_user_meta($meta_id, $user_id, $meta_key, $meta_value) { | |
// Change user_avatar to your Register Helper file upload name. | |
if( 'user_avatar' == $meta_key) { | |
$filename = $meta_value['fullpath']; | |
$filetype = wp_check_filetype( basename( $filename ), null ); | |
$wp_upload_dir = wp_upload_dir(); | |
$attachment = array( |
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
/* | |
Add custom validation for Register Helper fields when editing from profile page. | |
Requires Paid Memberships Pro and Register Helper Add On. | |
*/ | |
function my_pmprorh_user_profile_validate_rhfields($errors, $update, $user) { | |
if( isset( $_POST['my_errors'] ) ){ | |
$my_errors = $_POST['my_errors']; | |
foreach( $my_errors as $single_error){ | |
$errors->add('my_pmprorh_error',__($single_error)); |
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
// send WP new user email and PMPro admin change email after registering a member through a PMPro Zapier zap | |
// requires Paid Memberships Pro and PMPro Zapier add on | |
function my_pmpro_zapier_email_after_change_level( $level_id, $user_id ){ | |
if( isset( $_SERVER["REQUEST_URI"] ) && ( strpos( $_SERVER["REQUEST_URI"], "pmpro_zapier_webhook" ) !== false ) ){ | |
$user = get_userdata( $user_id ); | |
$pmpro_email = new PMProEmail(); | |
$pmpro_email->sendAdminChangeEmail( $user ); | |
wp_new_user_notification( $user_id, null, 'both' ); | |
} |
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
// Custom proration for levels with a subcription delay until a specified date (like "Y1-08-01"). | |
// Prorates initial payment based on days until end of subscription delay for level 1 | |
function my_pmprosd_prorate_delay( $level ) | |
{ | |
// change this to the ID of the membership level to prorate | |
if( $level->id == 1 ){ | |
// change this to the day of year the subscription delay ends, in MM-DD format | |
$subscription_day = "08-01"; |
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
// Always show the top discount code field on the checkout page for Paid Memberships Pro | |
function my_pmpro_always_show_discount_code() | |
{ | |
?> | |
<script> | |
jQuery(document).ready(function() { | |
jQuery('#other_discount_code_tr').show(); | |
jQuery('#other_discount_code_p').hide(); | |
jQuery('#other_discount_code').focus(); | |
}); |
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 | |
/* | |
This code assumes you already have a 'myrole' custom role created. | |
Members signing up get the 'myrole' role in addition to any other roles they already have. | |
Members cancelling are given the subscriber role. | |
Admin users are ignored. | |
Usable with or without the PMPro Roles Add On. | |
*/ | |
function my_pmpro_after_change_membership_level($level_id, $user_id) | |
{ |
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
function my_custom_memberslist_order($sqlQuery) | |
{ | |
echo "<a href=".admin_url('admin.php?page=pmpro-memberslist&enddate_sort=asc').">Sort by Enddate ASC</a><br>". | |
"<a href=".admin_url('admin.php?page=pmpro-memberslist&enddate_sort=desc').">Sort by Enddate DESC</a>"; | |
if(isset($_REQUEST['enddate_sort']) && ($_REQUEST['enddate_sort'] == 'asc' || $_REQUEST['enddate_sort'] == 'desc')) | |
{ | |
$sort_order = $_REQUEST['enddate_sort']; | |
global $wpdb; |
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
/* | |
Use the short version of the 2Checkout signup form when checking out. | |
After installing and activating this, you'll also need to enable "SHORT_FORM" in your 2Checkout settings. | |
See: https://knowledgecenter.2checkout.com/Documentation/05Ordering/10Minimize_required_checkout_data | |
*/ | |
function my_pmpro_twocheckout_short_billing( $request_array ) { | |
$short_form = array( | |
"SHORT_FORM" => "1" | |
); | |
return array_merge( $short_form, $request_array ); |
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
// example of adding Javascript to run after the checkout button is clicked | |
function my_pmpro_js_on_submit() { | |
?> | |
<script> | |
jQuery(document).ready( function(){ | |
jQuery("#pmpro_form").submit( function(){ | |
alert("hello world!"); | |
}); | |
}); | |
</script> |