Create wp-content/plugins/theme-my-login-custom.php
:
<?php
function redirect_tml_pages() {
$tml = theme_my_login()->get_object();
if ( is_user_logged_in() as $tml->is_tml_page( array( 'login', 'register' ) ) {
wp_redirect( home_url() );
exit;
}
}
add_action( 'template_redirect', 'redirect_tml_pages', 20 );
Thread Starter
Tom
(@tomhargreaves)
thanks for the reply here. unfortunately when i added this it didn’t work.
i managed to find a solution elsewhere though, so thought i’d follow-up in case anyone else wanted to do the same thing:
add_action('wp', 'add_login_check');
function add_login_check()
{
if ( is_user_logged_in() && is_page( [6070, 6071, 6072, 6073] ) ) {
wp_redirect('http://my_homepage_url');
exit;
}
}
add this to your wordpress functions.php file.
you then need to replace the 6070, 6071, 6072, 6073
numbers to whatever the page IDs are for your login, register, lostpassword and resetpass pages (these can be found in the URL when editing the page).
and finally you can change the wp_redirect('http://my_homepage_url');
to whatever webpage you want the users to be redirected to.
-
This reply was modified 6 years, 6 months ago by Tom.