Created
November 16, 2015 14:56
-
-
Save strangerstudios/24a655e9f50212956e61 to your computer and use it in GitHub Desktop.
Filter the teaser message text for a not logged in site visitor
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
function my_pmpro_not_logged_in_text_filter($text) | |
{ | |
global $post; | |
$access = pmpro_has_membership_access($post->ID, NULL, true); | |
$level_ids = $access[1]; | |
if(is_array($level_ids) && in_array(2, $level_ids)) | |
{ | |
$text = '<h4>This page requires a Bronze Account or higher.</h4><p>Already have an account? <a href="/login?redirect_to=' . urlencode($_SERVER['REQUEST_URI']) . '">Login Now »</a></p><p>New to this site? <a href="/membership-checkout/?level=2">Register Now »</a></p>'; | |
} | |
elseif(is_array($level_ids) && in_array(4, $level_ids) && !in_array(3, $level_ids) ) | |
{ | |
$text = '<h4>This page requires a Gold Account or higher.</h4><p>Already have an account? <a href="/login?redirect_to=' . urlencode($_SERVER['REQUEST_URI']) . '">Login Now »</a></p><p>New to this site? <a href="/membership-checkout/?level=4">Register Now »</a></p>'; | |
} | |
else | |
{ | |
$text = '<h4>This page requires a Silver Account or higher.</h4><p>Already have an account? <a href="/login?redirect_to=' . urlencode($_SERVER['REQUEST_URI']) . '">Login Now »</a></p><p>New to this site? <a href="/membership-checkout/?level=3">Register Now »</a></p>'; | |
} | |
return $text; | |
} | |
add_filter("pmpro_not_logged_in_text_filter", "my_pmpro_not_logged_in_text_filter", 5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment