Skip to content
All gists
Back to GitHub
Sign in
Sign up
Sign in
Sign up
{{ message }}
Instantly share code, notes, and snippets.
kimcoleman
/
my_swsales_hide_from_premium_members.php
Created
February 7, 2023 18:07
Star
0
Fork
0
Star
Code
Revisions
1
Embed
What would you like to do?
Embed
Embed this gist in your website.
Share
Copy sharable link for this gist.
Clone via HTTPS
Clone with Git or checkout with SVN using the repository’s web address.
Learn more about clone URLs
Download ZIP
Hide the active sale from users with level ID 1, 2, or 3.
Raw
my_swsales_hide_from_premium_members.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
<?php
/**
* Hide the active sale from users with level ID 1, 2, or 3.
*/
function my_swsales_hide_from_premium_members( ) {
// Return early if this is the admin.
if ( is_admin() ) {
return;
}
// If user has membership, don't activate the sale.
if ( pmpro_hasMembershipLevel( array( 1, 2, 3 ) ) ) {
add_filter( 'option_swsales_options', 'unset_swsales_active_sale_id' );
}
}
add_action( 'init', 'my_swsales_hide_from_premium_members' );
/**
* Return 0 (no sale active) for the swsales_options option.
*/
function unset_swsales_active_sale_id() {
$option = array( 'active_sitewide_sale_id' => '0' );
return $option;
}
Sign up for free
to join this conversation on GitHub
. Already have an account?
Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.