Category: Archive
AMP Auto Ads Script
MemberPress: Allow Users to Pause/Resume Subscriptions Only for Specific Memberships
function maybe_hide_pause_resume_links( $link, $sub ) { // Replace 123, 456 with the membership IDs which members can pause/resume subscriptions for. $products_to_allow = array( ‘123’, ‘456’ ); $product = $sub->product(); if( in_array( $product->ID, $products_to_allow ) ) { return $link; } else…Continue reading
MemberPress: Exclude Protected Posts From the Main Query
function mepr_exclude_protected_posts_from_query_block( $query ) { if (! is_admin() && $query->is_main_query()) { $posts_to_exclude = array(); $posts = get_posts(array(‘post_type’ => ‘post’, ‘posts_per_page’ => -1)); foreach ($posts as $post) { if (MeprRule::is_locked($post)) { $posts_to_exclude[] = $post->ID; } } if (! empty($posts_to_exclude)) { $query->set(‘post__not_in’,…Continue reading
MemberPress: ActiveCampaign – Add Custom Field to ActiveCampaign Subscriber Data in MemberPress
add_filter( ‘mepr-activecampaign-add-subscriber-args’, function( $args, $user ) { // Check if the username is set in the POST request and sanitize it $username = isset( $_POST[‘user_login’] ) ? sanitize_text_field( $_POST[‘user_login’] ) : ”; // Add the username to the custom field…Continue reading
MemberPress: ConvertKit – Remove ConvertKit Inactive Tag for Inactive Subscribers
// Remove the inactive tag function mepr_remove_ck_inactive_tag_from_subscriber($txn) { $contact = $txn->user(); $enabled = (bool)get_post_meta($txn->product_id, ‘_meprconvertkit_tag_override’, true); $active_tag_id = get_post_meta($txn->product_id, ‘_meprconvertkit_tag_override_id’, true); $inactive_tag_id = get_post_meta($txn->product_id, ‘_meprconvertkit_inactive_tag_override_id’, true); $ck = new MpConvertKit(); // Remove active tag if ($enabled && !empty($active_tag_id)) { $ck->remove_tag_from_subscriber($contact,…Continue reading
MemberPress: BuddyPress/BuddyBoss – Remove Users From All Groups, Forums, and Topics if Their Subscriptions Expire
add_action( ‘mepr-account-is-inactive’ , function ( $txn ) { if ( is_plugin_active( ‘buddypress/bp-loader.php’ ) && $txn instanceof MeprTransaction) { //first we need to make sure that the user isn’t active on another subscription $mepr_user = new MeprUser( $txn->user_id ); if (…Continue reading
MemberPress: WooCommerce – Show Specific WooCommerce Product Based on MemberPress Subscription
function always_display_products($visible, $prd_id) { // Get current user object $user = get_current_user(); // Get current user’s active subscriptions $active_subs = $user->active_product_subscriptions(‘ids’); // Check if the user has a specific subscription (ID 1234) and the current product ID is 222 if…Continue reading
MemberPress: Export a CSV File for All Corporate Accounts with Subaccounts in MemberPress
add_action(‘admin_init’, function() { global $wpdb; if (! isset( $_GET[‘export_subaccounts’] ) ) { return; } $corp_ids = $wpdb->get_results(“SELECT id FROM {$wpdb->prefix}mepr_corporate_accounts”); $csv_results = array(); foreach ( $corp_ids as $corp ) { // Get corp object $ca = new MPCA_Corporate_Account( $corp->id );…Continue reading
MemberPress: Display Corporate Account Logo for Sub-Users
add_shortcode(‘mepr-sub-logo’, function() { global $wpdb; $logo_slug = ‘mepr_logo’; // Custom field logo slug // Get current user $user = MeprUtils::get_currentuserinfo(); $caid = get_user_meta($user->ID, ‘mpca_corporate_account_id’); if (empty($caid)) { return; // Return if no corporate account ID is found } // Get…Continue reading