Filter the restricted message shown to logged-out visitors in Paid Memberships Pro

Filter the restricted message shown to logged-out visitors in Paid Memberships Pro on child sites.

Snippet Type

Execute on Child Sites

Snippet

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 );

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.