MemberPress: Disable Emails for Specific Memberships

function mepr_disable_membership_emails( $recipients, $subject, $message, $headers ) { if( strpos( $message, ‘Free Membership’ ) !== false ) { return null; } return $recipients; } add_filter( ‘mepr-wp-mail-recipients’, ‘mepr_disable_membership_emails’, 10, 4 );Continue reading

MemberPress: Send Email to User When Their User Role Is Changed

function mepr_email_user_role_change( $user_id, $new_role ) { $site_url = get_bloginfo( ‘wpurl’ ); $user_info = get_userdata( $user_id ); $to = $user_info->user_email; $subject = “Your role has changed: “.$site_url; // Email Subject $message = “Hello ” .$user_info->display_name . “, your role has changed…Continue reading

MemberPress: Whitelist Domains

function mepr_custom_is_domain_whitelisted() { $whitelist = array( “domain.com, domain1.com” ); //comma-separated list of domains $domain = parse_url( $_SERVER[ ‘HTTP_REFERER’ ], PHP_URL_HOST ); if ( !empty($domain ) && in_array( $domain, $whitelist ) ) { return true; //Exclude from paywall } return false;…Continue reading

MemberPress: Turn Off Auto-Rebill for Offline Gateway

//Turn off Auto rebill for offline gateway if a transactions expires function turn_off_auto_rebill_offline_gateway( $txn, $sub_status ) { if ( $txn->payment_method() instanceof MeprArtificialGateway && $sub = $txn->subscription() ) { $sub->status = MeprSubscription::$cancelled_str; $sub->store(); } } add_action( ‘mepr-transaction-expired’, ‘turn_off_auto_rebill_offline_gateway’, 9, 2 );…Continue reading

MemberPress: Change Non-Recurring Renewal Price

function mepr_change_product_renewal_price( $product_price, $coupon_code, $product ) { $user = new MeprUser( get_current_user_id() ); $subscriptions = $user->active_product_subscriptions( ‘ids’, true, true ); // change the 123 ID to the required one-time membership ID if ( $product->ID === 123 && in_array( $product->ID, $subscriptions…Continue reading

MemberPress: Bulk Delete All Expired Subscriptions

function mepr_delete_expired_txns() { $subscriptions = MeprSubscription::get_all(); if( is_array( $subscriptions ) && !empty( $subscriptions ) ) { foreach( $subscriptions as $subscription ) { $subscription = new MeprSubscription( $subscription->id ); if( $subscription->is_cancelled() && $subscription->is_expired() ) { $subscription->destroy(); } } } } add_action(…Continue reading