Skip to content

Instantly share code, notes, and snippets.

@ipokkel
Created August 20, 2024 10:09
Show Gist options
  • Save ipokkel/46bcf2a5f28c315e0a889136a5a57c7f to your computer and use it in GitHub Desktop.
Save ipokkel/46bcf2a5f28c315e0a889136a5a57c7f to your computer and use it in GitHub Desktop.
Example of a custom PMPro no access message body with a button link.
<?php
/**
* Customize the no access message with a button.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_no_access_message_body_with_button( $body, $level_ids ) {
global $pmpro_pages;
$body = '<p><strong>You must have one of the following membership levels to access this content:</strong></p><p>!!levels!!</p><p><a href="' . pmpro_url( 'levels' ) . '" class="pmpro_btn">Join Now</a></p>';
return $body;
}
add_filter( 'pmpro_no_access_message_body', 'my_pmpro_no_access_message_body_with_button', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment