Last active
September 11, 2025 05:58
-
-
Save JarrydLong/b046495fa5c7ef610a387cb29c99f974 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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