Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Created November 28, 2024 13:11
Show Gist options
  • Save andrewlimaza/5311a58655303923816d0a3266c7a330 to your computer and use it in GitHub Desktop.
Save andrewlimaza/5311a58655303923816d0a3266c7a330 to your computer and use it in GitHub Desktop.
Filter the PMPro Login URL for sites.
<?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