Skip to content

Instantly share code, notes, and snippets.

@JarrydLong
Last active September 11, 2025 05:58
Show Gist options
  • Select an option

  • Save JarrydLong/b046495fa5c7ef610a387cb29c99f974 to your computer and use it in GitHub Desktop.

Select an option

Save JarrydLong/b046495fa5c7ef610a387cb29c99f974 to your computer and use it in GitHub Desktop.
<?php //do not copy
/**
* This recipe removes the redirect referrer from the Login URL in the No Access message
*
* 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.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_remove_referrer_noaccess_message( $no_access_message_html, $level_ids ) {
//Current login url with a redirect refferer present
$current_login_url = wp_login_url( get_permalink() );
//New login url without a redirect refferer
$new_login_url = wp_login_url();
//Find the old url and replace it with the new one
$no_access_message_html = str_replace( $current_login_url, $new_login_url, $no_access_message_html );
return $no_access_message_html;
}
add_filter( 'pmpro_no_access_message_html', 'my_pmpro_remove_referrer_noaccess_message', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment