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: 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

MemberPress: Only Allow Coupon Once Per User

function custom_validate_coupon( $errors ) { global $wpdb; //If user is not logged in, then they’ve never used a coupon before if( !MeprUtils::is_user_logged_in() ) { return $errors; } $coupon_code = ( isset( $_POST[‘mepr_coupon_code’] ) && !empty( $_POST[‘mepr_coupon_code’] ) )?stripslashes( $_POST[‘mepr_coupon_code’] ):”;…Continue reading

MemberPress: Remove State Text Field

function mepr_remove_state_field() { global $post; $mepr_options = MeprOptions::fetch(); $is_product_page = ( false !== ( $prd = MeprProduct::is_product_page($post) ) ); if( $mepr_options->global_styles || $is_product_page ) { ?>Continue reading