|
/* |
|
Edit Teaser Messages Depending on Content |
|
|
|
In the example below, we have 3 levels with IDs 1, 2, and 3. Level 1 is a free level. |
|
Level 2 is a paid level. Level 3 is a higher-tiered paid level. |
|
|
|
So each level is an upgrade over the other. All level 2 members have access to level 1 content, etc. |
|
|
|
When showing teaser text, we check if the current post is available to free members. |
|
If so, we show a link to register for the free level. If not, we show a link to the paid level. |
|
|
|
Change the level IDs, logic, and text to fit your needs. Then paste this into your active theme's functions.php |
|
or a custom plugin. |
|
*/ |
|
|
|
//for not logged in users |
|
function pmpro_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(1, $level_ids)) |
|
{ |
|
$text = ' |
|
This page is restricted to Free level members or higher.<br /><br /> |
|
<strong>Already have an account? <a href="/login?redirect_to=' . urlencode($_SERVER['REQUEST_URI']) . '">Login Now »</a></strong> |
|
<strong>New to this site? <a href="/membership-checkout/?level=1">Register Now »</a></strong> |
|
'; |
|
} |
|
else |
|
{ |
|
$text = ' |
|
This page is restricted to PMPro level members or higher.<br /><br /> |
|
<strong>Already have an account? <a href="/login?redirect_to=' . urlencode($_SERVER['REQUEST_URI']) . '">Login Now »</a></strong> |
|
<strong>New to this site? <a href="/membership-checkout/?level=2">Register Now »</a></strong> |
|
'; |
|
} |
|
|
|
return $text; |
|
} |
|
add_filter("pmpro_not_logged_in_text_filter", "pmpro_pmpro_not_logged_in_text_filter"); |
|
|
|
//for logged-in non-members |
|
function pmpro_pmpro_non_member_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(1, $level_ids)) |
|
{ |
|
$text = ' |
|
This page is restricted to Free level members or higher. <a href="/membership-checkout/?level=1">Upgrade Now »</a></strong> |
|
'; |
|
} |
|
else |
|
{ |
|
$text = ' |
|
This page is restricted to PMPro level members or higher. <a href="/membership-checkout/?level=2">Upgrade Now »</a></strong> |
|
'; |
|
} |
|
|
|
return $text; |
|
} |
|
add_filter("pmpro_non_member_text_filter", "pmpro_pmpro_non_member_text_filter"); |