php – redirect user from login page if is logged

Question

Is possible to use the is_page('template-name') inside a plugin code?
I need to check if the user is logged in and is trying to view the login page. I want to redirect to the profile page

<?php 
if( is_user_logged_in() && is_page('login') ){
 wp_safe_redirect( site_url('user-profile') );
 exit;
}
?>

Not sure if this will work in a plugin when the template_redirect action is called.

0
devdev 2 months 2022-10-01T13:30:49-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse