Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
Last active November 24, 2020 22:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save strangerstudios/5913034 to your computer and use it in GitHub Desktop.
Save strangerstudios/5913034 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(pmpro_url("levels"));
exit;
}
}
add_action('template_redirect', 'my_template_redirect_require_membership_access');
@olaronymax
Copy link

Hi, the plugin not work if use learn dash. All pages and CPTs ok but in swfd-course not work redirect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment