Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Created February 4, 2021 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewlimaza/ae0248614e5f7a8731054a2580b58f8c to your computer and use it in GitHub Desktop.
Save andrewlimaza/ae0248614e5f7a8731054a2580b58f8c to your computer and use it in GitHub Desktop.
Give user access to post or page dynamically for Addon Packages All Access filter
<?php
/**
* Give access to a certain post/page for specific users.
* Please add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmproap_all_access_levels($levels, $user_id, $post_id) {
if ( $post_id == 71 && $user_id == 1 ) { // Change post ID and user ID value. Adjust this accordingly.
$levels = array('4');
}
return $levels;
}
add_filter( 'pmproap_all_access_levels', 'my_pmproap_all_access_levels', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment