Footer ) has an image that is link for a page - external to my site - from Google Docs. I want to restrict access to this Google Docs page as follows: - If the person who clicked on the image / link is not logged in , I call the login.php Wordpress (WP); - If it's logged in I'll open the Google Docs page.
I thought of using the file functions.php
of WP, the idea is more or less this, just do not know how to check the click with PHP or with the WP itself:
function logadoRedireciona() {
if ( is_user_logged_in() ) { // se estiver logado
// vá para o link
wp_redirect( 'https://docs.google.com/' );
exit;
} else { // se não
// faça o login
wp_login_form();
}
}
add_action ( 'wp_footer' , 'logadoRedireciona' );
Does WP have some template tag that checks links or URLs ? Or using PHP, how do I do that?