MemberPress Code Snippets

MemberPress code snippet for use inside WordPress theme templates. Use this code to create conditional rules and control access to content based on MemberPress access levels.

Show or Hide Content Based on a MemberPress plugin Rule

<div><?php
	if(class_exists('MeprRule')) 
		{
		if(MeprRule::is_protected_by_rule(279))
			{ the_field( 'cta_video_embed' ); //for non-members
			}
		else
			{ the_field( 'premium_embed' ); // for members
			}
		}
?></div>

An alternate way to show a video based on membership access is this:

<div> <?php if(MeprRule::is_allowed_by_rule(279)): the_field( 'premium_embed' ); endif; ?> </div>

MemberPress Login Logout Link

Add the following code snippet to your theme template file

<?php echo do_shortcode("[mepr-login-link]"); ?>

Hire a WordPress Expert

Get hourly and project based theme customization, theme tweaks, and development help from an experienced Kelowna WordPress developer.  We’ve been building WordPress websites full-time for over a decade. We can help you.