Skip to content

Instantly share code, notes, and snippets.

@ipokkel
Created February 25, 2025 09:03
Show Gist options
  • Save ipokkel/98c0f6fb978f88c7ae523695dc20803b to your computer and use it in GitHub Desktop.
Save ipokkel/98c0f6fb978f88c7ae523695dc20803b to your computer and use it in GitHub Desktop.
<?php
/**
* Replace <h2> with <h5> in the no access message HTML.
*
* 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 h2_to_h5_no_access_message_html( $no_access_message_html, $level_ids ) {
// replace <h2> with <h5>
$no_access_message_html = str_replace( '<h2', '<h5', $no_access_message_html );
$no_access_message_html = str_replace( '</h2>', '</h5>', $no_access_message_html );
return $no_access_message_html;
}
add_filter( 'pmpro_no_access_message_html', 'h2_to_h5_no_access_message_html', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment