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

Multipost Query Loop

add_filter( ‘generateblocks_query_loop_args’, function( $query_args, $attributes ) { $attributesArray = array_column($attributes[‘htmlAttributes’], ‘value’, ‘attribute’); if (isset($attributesArray[‘data-posts’])) { $posts = explode(‘,’, $attributesArray[‘data-posts’]) ?? []; return array_merge( $query_args, array( ‘post_type’ => $posts, ) ); } return $query_args; }, 10, 2 );Continue reading

Remove JQuery Migrate Script

function remove_jquery_migrate($scripts) { if (!is_admin() && isset($scripts->registered[‘jquery’])) { $script = $scripts->registered[‘jquery’]; if ($script->deps) { // Check whether the script has any dependencies $script->deps = array_diff($script->deps, array(‘jquery-migrate’)); } } } add_action(‘wp_default_scripts’, ‘remove_jquery_migrate’);Continue reading

Year Shortcode

// Copy the Shortcode in the Insertion box below and paste it wherever you want the copyright symbol + year to be displayed. // This will output © 2023 or the current year automatically. echo “© ” . date( ‘Y’…Continue reading

Custom Email Template

// create the HTML for the custom template function pw_edd_custom_email_template() { echo ‘ ‘; echo ‘ ‘; echo ‘{email}’; // this tag is required in order for the contents of the email to be shown echo ‘ ‘; echo ‘…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