Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save kimcoleman/fb7097d6cfee174d981b6a0b6d3ed73e to your computer and use it in GitHub Desktop.
Save kimcoleman/fb7097d6cfee174d981b6a0b6d3ed73e to your computer and use it in GitHub Desktop.
Edit Teaser Messages Depending on Content
<?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