Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Created March 18, 2024 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewlimaza/c573c744388096dff12351e2e79a3e20 to your computer and use it in GitHub Desktop.
Save andrewlimaza/c573c744388096dff12351e2e79a3e20 to your computer and use it in GitHub Desktop.
Redirect logged-in people away from the login page of PMPro.
<?php
/**
* Redirect logged-in users away from the login page if already logged-in.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_login_page_redirect() {
global $pmpro_pages;
if ( is_page( $pmpro_pages['login'] ) && is_user_logged_in() ) {
wp_redirect( home_url( '/page-slug/' ) );
exit;
}
}
add_action( 'template_redirect', 'my_pmpro_login_page_redirect' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment