Developers can use these filters, actions, and functions to change who can buy an Addon Package, which level a buyer checks out with, which post types can be sold, and what happens when a member gains or loses access.
Add custom code to your site using your preferred method. We recommend a customizations plugin. To set an expiration for package access, see the PMPROAP_EXP_DAYS constant.
Filters
pmproap_all_access_levels
Sets membership levels that can view every package without buying it. Members of these levels must also hold a level that is checked in the package’s Require Membership settings. When this filter returns levels, the Purchase Required message tells visitors the content is free for those levels.
apply_filters( 'pmproap_all_access_levels', array $level_ids, int $user_id, int $post_id );
Parameters
$level_ids: array; Membership level IDs with access to all packages. Default empty array.$user_id: int; The ID of the user whose access is being checked.$post_id: int; The ID of the package being checked.
Example
function my_pmproap_all_access_levels( $level_ids, $user_id, $post_id ) {
// Members of level 3 get every package for free.
$level_ids[] = 3;
return $level_ids;
}
add_filter( 'pmproap_all_access_levels', 'my_pmproap_all_access_levels', 10, 3 );
pmproap_text_level_id
Filters the membership level used for package checkout links, on the package, in the shortcode list, and on checkout links that pass only ap. By default, the Add On uses the first of the user’s current levels that is required for the package, then the first free required level. Return false or an empty value to send the visitor to the Membership Levels page instead.
apply_filters( 'pmproap_text_level_id', int|null $text_level_id, int $post_id, int|null $user_id, array $post_levels );
Parameters
$text_level_id: int|null; The level ID the Add On chose, ornullif it found none.$post_id: int; The ID of the package.$user_id: int|null; The ID of the user checking out, ornullfor a logged-out visitor.$post_levels: array; The level IDs checked in the package’s Require Membership settings.
Example
function my_pmproap_text_level_id( $text_level_id, $post_id, $user_id, $post_levels ) {
// Send visitors with no qualifying level to checkout for level 2.
if ( empty( $text_level_id ) && in_array( 2, $post_levels ) ) {
$text_level_id = 2;
}
return $text_level_id;
}
add_filter( 'pmproap_text_level_id', 'my_pmproap_text_level_id', 10, 4 );
pmproap_supported_post_types
Filters the post types that can be sold as packages. It controls which edit screens get the PMPro Addon Package Settings box, and which post types the pmpro_addon_packages shortcode lists. Post types from the Custom Post Type (CPT) Membership Access Add On get the settings box without this filter, but the shortcode only lists them if you add them here.
apply_filters( 'pmproap_supported_post_types', array $post_types );
Parameters
$post_types: array; Post type names. Defaultarray( 'page', 'post' ). In the shortcode withinclude="subpages", the default isarray( 'page' ).
Example
function my_pmproap_supported_post_types( $post_types ) {
$post_types[] = 'recipe';
return $post_types;
}
add_filter( 'pmproap_supported_post_types', 'my_pmproap_supported_post_types' );
pmproap_shortcode_query_args
Filters the arguments passed to get_posts() when the pmpro_addon_packages shortcode builds its list. Use this to change which packages are shown or how they are sorted.
apply_filters( 'pmproap_shortcode_query_args', array $args );
Parameters
$args: array; The query arguments. By default the query gets published posts with a_pmproap_pricegreater than 0, using the shortcode’sorder,orderby,exclude, andincludeattributes and the post types frompmproap_supported_post_types.
pmproap_edit_price_capability
Filters the capability a user needs to see the PMPro Addon Package Settings box and save a package price. Users with manage_options can always set prices.
apply_filters( 'pmproap_edit_price_capability', string $capability );
Parameters
$capability: string; The required capability. Defaultpmpro_membershiplevels.
Example
function my_pmproap_edit_price_capability( $capability ) {
// Let editors set package prices.
return 'edit_others_posts';
}
add_filter( 'pmproap_edit_price_capability', 'my_pmproap_edit_price_capability' );
pmproap_supported_offsite_gateways
Filters the offsite payment gateways where the Add On gives package access when the order is marked as successful, reading the package from the order notes.
apply_filters( 'pmproap_supported_offsite_gateways', array $gateways );
Parameters
$gateways: array; Gateway slugs. Defaultarray( 'paypalstandard', 'ccbill' ).
Actions
pmproap_action_add_to_package
Fires after a user is given access to a package. This runs after a checkout, when an offsite gateway order is marked successful, and when an administrator gives a package from the Edit User screen. The Add On uses this action to set the expiration date when PMPROAP_EXP_DAYS is defined.
do_action( 'pmproap_action_add_to_package', int $user_id, int $post_id );
Parameters
$user_id: int; The ID of the user who was given access.$post_id: int; The ID of the package.
Example
function my_pmproap_action_add_to_package( $user_id, $post_id ) {
// Save the date the member got this package.
update_user_meta( $user_id, 'my_package_' . $post_id . '_added', current_time( 'mysql' ) );
}
add_action( 'pmproap_action_add_to_package', 'my_pmproap_action_add_to_package', 10, 2 );
pmproap_action_remove_from_package
Fires after a user’s access to a package is removed, either by an administrator from the Edit User screen or because the access expired.
do_action( 'pmproap_action_remove_from_package', int $user_id, int $post_id );
Parameters
$user_id: int; The ID of the user who lost access.$post_id: int; The ID of the package.
Functions
pmproap_hasAccess
Checks whether a user has access to a package, either because they bought it, were given it, or hold an all access level. It does not check the package’s required levels, so pair it with pmpro_hasMembershipLevel() if you need both. If PMPROAP_EXP_DAYS is set and the access has expired, this function removes the access and returns false.
pmproap_hasAccess( int $user_id, int $post_id );
Parameters
$user_id: int; The ID of the user to check.$post_id: int; The ID of the package.
Returns true if the user has access, false if not.
Example
if ( function_exists( 'pmproap_hasAccess' ) && pmproap_hasAccess( get_current_user_id(), 123 ) ) {
echo '<a href="/downloads/croissant-schedule.pdf">Download the lamination schedule</a>';
}
pmproap_addMemberToPost
Gives a user access to a package and fires pmproap_action_add_to_package. This is the same function the Add On runs after checkout.
pmproap_addMemberToPost( int $user_id, int $post_id );
Parameters
$user_id: int; The ID of the user.$post_id: int; The ID of the package.
pmproap_removeMemberFromPost
Removes a user’s access to a package and fires pmproap_action_remove_from_package.
pmproap_removeMemberFromPost( int $user_id, int $post_id );
Parameters
$user_id: int; The ID of the user.$post_id: int; The ID of the package.
pmproap_isPostLocked
Checks whether a post is set up as a package: it has a price and at least one level checked in its own Require Membership settings.
pmproap_isPostLocked( int $post_id );
Parameters
$post_id: int; The ID of the post to check.
Returns true if the post is a package, false if not.
Get Support From Our Team of Experts
Have a question about how to use this feature? Our Support Page outlines three ways to get support.
Our Max plans include hands-on help customizing your membership site and implementing new features. Upgrade to PMPro Max now »
Last updated on November 19, 2026