MemberPress: Add Category Exception to All Post Rule

function mepr_override_protection( $protect, $post ) { if( has_category( ‘category_slug_here’, $post ) ) { $protect = false; } return $protect; } function mepr_override_content_protection( $protect, $post, $uri ) { return mepr_override_protection( $protect, $post ); } function mepr_override_redirection_protection( $protect, $uri, $delim ) {…Continue reading

MemberPress: Require Specific Coupon to Register

function mepr_only_with_coupon( $errors ) { $membership_id = 123; //Change this ID to your membership ID $coupons = array( ‘IMRECOMMENDED’, ‘DISCOUNTED’ ); //Change these titles to your coupon title(s) if( $_POST[‘mepr_product_id’] == $membership_id ) { if( !isset( $_POST[‘mepr_coupon_code’] ) || empty(…Continue reading

MemberPress: Require Coupon at Checkout

function mepr_must_fill_out_coupon_code( $errors ) { if( !isset($_POST[‘mepr_coupon_code’]) || empty($_POST[‘mepr_coupon_code’] ) ) { $errors[] = “You must fill out the Coupon code field before registering.”; } return $errors; } add_filter( ‘mepr-validate-signup’, ‘mepr_must_fill_out_coupon_code’, 11, 1 );Continue reading

MemberPress: Add Tag Support for Lessons and Quizzes

function mepr_add_tags_to_lessons(){ register_taxonomy_for_object_type( ‘post_tag’, ‘mpcs-lesson’ ); } add_action( ‘init’, ‘mepr_add_tags_to_lessons’ ); function mepr_add_tags_to_quiz () { register_taxonomy_for_object_type( ‘post_tag’, ‘mpcs-quiz’ ); } add_action ( ‘init’, ‘mepr_add_tags_to_quiz’ );Continue reading

MemberPress: Disable Admin Password Lost/Changed Email

function mepr_disable_admin_pw_changed_email( $recipients, $subject, $message, $headers ) { if( strpos( $subject, ‘Password Lost/Changed’ ) !== false ) { $recipients = array(); // no recipients } return $recipients; } add_filter( ‘mepr-wp-mail-recipients’, ‘mepr_disable_admin_pw_changed_email’, 11, 4 );Continue reading

MemberPress: Hide Protected Posts on Archive Page

function mepr_exclude_protected_posts_from_archive( $query ) { if( !$query->is_admin && $query->is_archive() && $query->is_main_query() ) { $posts_to_exclude = array(); $posts = get_posts( array( ‘numberposts’ => -1 ) ); foreach( $posts as $post ) { if( MeprRule::is_locked( $post ) ) { $posts_to_exclude[] = $post->ID;…Continue reading

MemberPress: Hide Protected Posts from Search Results

function mepr_exclude_protected_posts_from_search( $query ) { if( !$query->is_admin && $query->is_search && $query->is_main_query() ) { $posts_to_exclude = array(); $posts = get_posts( array( ‘post_type’ => get_post_types(), ‘numberposts’ => -1 )); foreach( $posts as $post ) { if( MeprRule::is_locked( $post ) ) { $posts_to_exclude[]…Continue reading