Why the twig condition snippet user.isAnonymous() doesn't work? It seems correct, referring to Drupal API.
This is my whole code 
 

{% if not user.isAnonymous() %}

  <div class="user-welcome-wrapper position-relative">
    <div class="user-in" title="{{ name|striptags|trim }}">
      {{ user_picture }}
    </div>

    <div class="my-custom-dropdown">
      <a href="/user">Il mio Profilo</a>
      <a href="/user/logout">Esci (Log out)</a>
    </div>

  </div>

{% elseif user.isAnonymous() %}

  <div class="user-login-link">
    <a href="/user/login" class="btn-login" title="Accedi al sito">
      <span class="login-text">Accedi</span>
    </a>
  </div>
{% endif %}

Thanks for your suggestions 

Comments

jaypan’s picture

Twig functions don't use parenthesis. Try user.isAnonymous. You can also try logged_in

Contact me to contract me for D7 -> D10/11 migrations.

senzaesclusiva’s picture

Thanks @jaipan, always so kind and precise. I had dragged some PHP old habits into Twig :)

Now it works as it should.

Thanks again

jaypan’s picture

Happy to have helped and know I have done so in the past as well :) 

Contact me to contract me for D7 -> D10/11 migrations.

jafoxol’s picture

Hi, thanks for the explanation, it helps me too.