Skip to content

Instantly share code, notes, and snippets.

@femiyb
Forked from strangerstudios/pmpro_customizations.php
Last active May 27, 2020 07:20
Show Gist options
  • Select an option

  • Save femiyb/8d261f65eb097b65aec0bef77c41acfb to your computer and use it in GitHub Desktop.

Select an option

Save femiyb/8d261f65eb097b65aec0bef77c41acfb to your computer and use it in GitHub Desktop.
Redirect users away from posts requiring membership with Paid Memberships Pro.
<?php
/*
Plugin Name: PMPro Customizations
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Customizations for Paid Memberships Pro
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
//redirect to login or homepage if user is logged out or not a member
function my_template_redirect_require_membership_access()
{
if(!pmpro_has_membership_access())
{
wp_redirect( wp_login_url() );
exit;
}
}
add_action('template_redirect', 'my_template_redirect_require_membership_access');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment