Forked from kimcoleman/pmpro_pmpro_not_logged_in_text_filter.php
Created
November 3, 2022 18:21
-
-
Save MaryOJob/2767fb1415649626721d5d93acdb8c63 to your computer and use it in GitHub Desktop.
Edit Teaser Messages Depending on Content
This file contains hidden or 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
<?php | |
/** | |
* Edit Teaser Messages Depending on Content | |
* | |
*/ | |
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( 7, $level_ids ) ) { | |
$text = '<h3 class="text-center">This content requires a Free Account or higher.</h3><hr />'; | |
$text .= '<div class="row text-center">'; | |
$text .= '<div class="medium-6 columns"><h4>Already have an account?</h4><p><a href="/login?redirect_to=' . urlencode( get_the_permalink( $post->ID ) ) . '">Log In</a></p></div>'; | |
$text .= '<div class="medium-6 columns"><h4>New to this site?</h4><p><a href="/membership-checkout/?level=7">Register Now</a></div>'; | |
$text .= '</div>'; | |
} else { | |
$text = '<h3 class="text-center">This page requires a Plus Account or higher.</h3><hr />'; | |
$text .= '<div class="row text-center">'; | |
$text .= '<div class="medium-6 columns"><h4>Already have an account?</h4><p><a href="/login?redirect_to=' . urlencode( get_the_permalink( $post->ID ) ) . '">Log In</a></p></div>'; | |
$text .= '<div class="medium-6 columns"><h4>New to this site?</h4><p><a href="/membership-checkout/?level=20">Register Now</a></div>'; | |
$text .= '</div>'; | |
} | |
return $text; | |
} | |
add_filter( 'pmpro_not_logged_in_text_filter', 'pmpro_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