Archives: Snippets
MemberPress: Unsubscribed Memberships Shortcode
add_shortcode( ‘mepr-unsubscribed-memberships’, function () { $args = array( ‘post_type’ => ‘memberpressproduct’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ); $memberships = new WP_Query( $args ); ob_start(); if ( $memberships->have_posts() ) { echo ‘ ‘; while ( $memberships->have_posts() ) { $memberships->the_post(); $post_ID…Continue reading
MemberPress: Restrict Signups for US-Based Users
function limit_signups_to_excluded_regions( $errors ) { // Check if the country field is set If ( isset( $_POST[ ‘mepr-address-country’ ] ) ) { $country = sanitize_text_field( wp_unslash( $_POST[ ‘mepr-address-country’ ] ) ); // Exclude EU countries if ( $country == ‘US’…Continue reading
MemberPress: Restrict Signups for EU-Based Users
function limit_signups_to_excluded_regions( $errors ) { // List of EU country codes $eu_countries = array( ‘AT’, ‘BE’, ‘BG’, ‘HR’, ‘CY’, ‘CZ’, ‘DK’, ‘EE’, ‘FI’, ‘FR’, ‘DE’, ‘EL’, ‘HU’, ‘IE’, ‘IT’, ‘LV’, ‘LT’, ‘LU’, ‘MT’, ‘NL’, ‘PL’, ‘PT’, ‘RO’, ‘SK’, ‘SI’, ‘ES’,…Continue reading
MemberPress: Restrict Signups for Northern Ireland-Based Users
function limit_signups_to_excluded_regions($errors) { // Check if the country field is set if ( isset( $_POST[ ‘mepr-address-country’ ] ) ) { $country = sanitize_text_field( wp_unslash( $_POST[ ‘mepr-address-country’ ] ) ); // Exclude Northern Ireland under UK country code if( $country ==…Continue reading
MemberPress: Adding Credit Card and Expiry Information to Subscriptions Table
// Add the “Card/Expiry” column header function mepr_add_subscriptions_th($user, $subs) { ?> Card/ExpiryContinue reading
MemberPress: Move “Upgrade” Button to after Subscriptions Tab
add_action(‘wp_footer’, function() { ?>Continue reading
MemberPress: Rearranging Navigation Items On The Account Page
add_action(‘wp_head’, function() { ?>Continue reading
Featured Images of the Current User’s All Active Memberships
/** * Display featured images of the current user’s active memberships * Add the [membership_thumbnail] shortcode to display the featured images of all active memberships of the current user. */ function custom_membership_thumbnail_shortcode() { if ( !is_user_logged_in() ) return; $user =…Continue reading
MemberPress: Hide the Cancel Subscription Option for the Set Number of Months
add_filter( ‘mepr_custom_cancel_link’, function( $link, $sub ) { // Get the subscription start time as a timestamp $subscription_start = strtotime( $sub->created_at ); // Get the current time as a timestamp $current_time = time(); // Calculate the number of months passed since…Continue reading