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: Kit (formerly ConvertKit) – Remove Kit 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: 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

Unattached Media Cleanup (copy)

// Schedule the event if it is not already scheduled function schedule_unattached_media_cleanup() { if (!wp_next_scheduled(‘delete_unattached_media_event’)) { wp_schedule_event(time(), ‘daily’, ‘delete_unattached_media_event’); } } add_action(‘wp’, ‘schedule_unattached_media_cleanup’); // Hook the function to the scheduled event add_action(‘delete_unattached_media_event’, ‘delete_unattached_media’); // Function to delete unattached media function…Continue reading

Login Redirect

function my_login_redirect($redirect_to, $request, $user) { return (in_array(‘administrator’, $user->roles)) ? $redirect_to : home_url(‘/gesetzesportal’); } add_filter(‘login_redirect’, ‘my_login_redirect’, 10, 3);Continue reading