Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andrewlimaza/d68885c78a5f58cadd0dcf247e9e4423 to your computer and use it in GitHub Desktop.
Save andrewlimaza/d68885c78a5f58cadd0dcf247e9e4423 to your computer and use it in GitHub Desktop.
Give temporary access to anyone with a special phrase / code to Paid Memberships Pro restricted content
<?php
/**
* This will allow any post or feed to be open if a user has a special passphrase or key.
* Please change 'abc' to a special passphrase/secret key and change this regularly.
* This will open any restricted post if a parameter of `&my-key=abc` is passed in the URL, for example my-site.com/feed/?my-key=abc
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_rss_access_filter($hasaccess, $mypost, $myuser, $post_membership_levels) {
// Some special key, don't share with everyone. Be sure to change this value regularly.
if( $_REQUEST['my-key'] === 'abc' ){
$hasaccess = true;
}
return $hasaccess;
}
add_filter('pmpro_has_membership_access_filter', 'my_pmpro_rss_access_filter', 10, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment