I’m trying to change an element in the WP Front End accordingly with a previous validation (if the user is logged in). Most concretly my code would be something like this:
<?php
if ( is_user_logged_in() ) {
// html button
} else {
// different html button
}
?>
To make it work I thought that a HTML block from WP would do the trick however is not working.
Does anyone know how can I achieve this?
Thanks in advance
2
Answers
Finally I was able to solved it. I share my solution:
It actually works. I’ve just tried it. Just make sure you have a session you are logged in and one in a private window that you are not logged in. Besides that you can also check (after ensure they are logged in, to avoid errors) what kind of role the user is and decide accordingly.