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 | |
/* | |
*/ | |
function my_pmpro_add_directory_page_numbers($title){ | |
global $post, $pmpro_pages; | |
$pn = 0; | |
if( isset($_REQUEST['pn'] ) ) | |
{ | |
$pn = sanitize_text_field( $_REQUEST['pn'] ); | |
} |
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
// preserve requested redirect with PMPro Member Homepages | |
// forked from @greathmaster | |
function pmpromh_modified_login_redirect($redirect_to, $request, $user) | |
{ | |
if(isset($request) && $redirect_to != admin_url()) | |
return $request; | |
//check level | |
if(!empty($user) && !empty($user->ID) && function_exists('pmpro_getMembershipLevelForUser')) { | |
$level = pmpro_getMembershipLevelForUser($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
.pmpro_checkout-field-bstate { | |
display: none; | |
} |
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
// don't cancel memberships when woocommerce orders go on hold | |
function my_pmpro_woocommerce_on_hold_keep_membership() | |
{ | |
remove_action( 'woocommerce_subscription_status_on-hold', 'pmprowoo_cancelled_subscription', 10, 1 ); | |
remove_action( 'woocommerce_subscription_status_on-hold_to_active', 'pmprowoo_activated_subscription', 10, 1 ); | |
} | |
add_action('init', 'my_pmpro_woocommerce_on_hold_keep_membership'); |
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_pmprowoo_active_preserve_startdate( $level_id, $user_id ) | |
{ | |
global $wpdb; | |
if( $level_id != 0 && did_action( "woocommerce_subscription_status_active" ) ) | |
{ | |
$startdate = get_user_meta( $user_id, "pmprowoo_startdate_$level_id", true ); | |
if( !empty($startdate) ) | |
{ | |
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->pmpro_memberships_users SET startdate = %s WHERE user_id = %d AND status = 'active'", $startdate, $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
/* | |
Change cancellation to set expiration date for next payment instead of cancelling immediately. | |
Assumes orders are generated for each payment (i.e. your webhooks/etc are setup correctly). | |
Since 2015-09-21 and PMPro v1.8.5.6 contains code to look up next payment dates via Stripe and PayPal Express APIs. | |
*** Updated 2018-11-16 to also check for calls from PayFlow Recurring Orders Add On | |
*/ | |
//before cancelling, save the next_payment_timestamp to a global for later use. (Requires PMPro 1.8.5.6 or higher.) | |
function my_pmpro_before_change_membership_level_customization($level_id, $user_id) { | |
global $pmpro_pages, $wpdb, $pmpro_stripe_event, $pmpro_next_payment_timestamp, $cancelling; | |
// Is this being called from the PayFlow Recurring Orders Add On? |
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
// Remove shipping address from PMPro-generated emails when using Shipping Add On | |
function my_pmproship_remove_email_filter() | |
{ | |
remove_filter( "pmpro_email_body", "pmproship_pmpro_email_body", 10, 2 ); | |
} | |
add_action( "init", "my_pmproship_remove_email_filter"); |
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 checks to see if the user has a 'pending' check order and will deny access whever member content is called. | |
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function pmpro_deny_if_user_is_pending( $hasaccess, $post, $user, $levels ) { | |
$order = new MemberOrder(); | |
$order->getLastMemberOrder( $user->ID, array( 'pending', '', 'check' ) ); |
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
//show a 404 page when trying to access a profile page for members with "Hide from Directory?" checked and/or don't have a specific level | |
function my_pmpromd_profile_preheader() | |
{ | |
// -------- Edit this line to determine which levels get profile pages ---------- // | |
$directory_levels = array(1, 2, 3); | |
global $post, $pmpro_pages, $current_user, $wp_query; | |
if(!empty($post->ID) && $post->ID == $pmpro_pages['profile']) | |
{ | |
//Get the profile user |