Created
November 28, 2024 13:11
-
-
Save andrewlimaza/5311a58655303923816d0a3266c7a330 to your computer and use it in GitHub Desktop.
Filter the PMPro Login URL for sites.
This file contains 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 | |
/** | |
* Adjust the login URL value that PMPro uses and override it to use a custom one. | |
* Use this to force the login URL even if the frontend URL page is set. | |
* You can tweak this further based on current page, condtionals and more. This is a starting point. | |
* To add this code to your site follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_pmpro_login_url( $login_url, $redirect, $reauth ) { | |
$login_url = '/login'; // Change the slug of this. | |
if ( ! empty( $redirect ) ) { | |
$login_url = add_query_arg( 'redirect_to', urlencode( $redirect ), $login_url ); | |
} | |
return $login_url; | |
} | |
add_filter( 'pmpro_login_url', 'my_pmpro_login_url', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment