Created
December 18, 2025 13:35
-
-
Save dwanjuki/cc0b9a1abdfdcc0ee62cfba37bd57eab 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 | |
| /** | |
| * Redirect to the PMPro Login page after logout. | |
| * | |
| * 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 wp_redirect_to_pmpro_login_after_logout() { | |
| global $pmpro_pages; | |
| // Bail if PMPro is inactive or PMPro login page isn't set. | |
| if ( empty( $pmpro_pages ) || empty( $pmpro_pages['login'] ) ) { | |
| return; | |
| } | |
| // Get login page URL. | |
| $pmpro_login_url = get_permalink( $pmpro_pages['login'] ); | |
| // Redirect. | |
| wp_safe_redirect( $pmpro_login_url ); | |
| exit; | |
| } | |
| add_action( 'wp_logout', 'wp_redirect_to_pmpro_login_after_logout' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment