0
At the bottom (footer) has an image that is link to a page - external to my site - Google Docs. I want to restrict access to this page of Google Docs as follows: - If who clicked on the image/link is not logged, page login.php Wordpress (WP); - If you are logged in I open the Google Docs page.
I thought I’d use the file functions.php
from WP, the idea is more or less this, just do not know how to check the click with PHP or with 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' );
The WP has some template that checks links or Urls? Or using PHP, how can I do this?
I didn’t test it, but see if it works.
– Lollipop
Thank you. I’m pretty new to WP, so forgive me for the questions: the first snippet of code goes in footer.php? and the second on functions, right?
– Alexandre Soares da Silva
Exactly!.....
– Lollipop
One more thing the image, the image/link in question was inserted in the footer through a widget. The theme I’m using is the crumina (widget, Jetpack image). Complicated, right?
– Alexandre Soares da Silva
The question is whether you can detect if you are logged in or not to put a link in the image depending on this.
– Lollipop