I'm using the profile module and am trying to display a profile edit button on your personal profile page.

my profile.html.twig:

<div class="m-section__content a-container">
{% if is_current_user %}
  <div class="a-container u-margin-bottom">
    <div class="a-cta ">
      <a class="a-cta__container" href="{{ url }}/edit">
        <span class="icon-arrow-right a-cta__icon"></span>
        <span class="a-cta__text">{{ "Edit profile"|t }}</span>
  {% endif %}
  <div class="u-grid u-grid--with-margins">
    <div class="u-grid__col-7-12">
      <table class="m-table">
          {{ content|without('field_image', 'field_extra', 'field_tags') }}
      <p>{{ content.field_extra }}</p>
    <div class="u-grid__col-5-12">
      {{ content.field_image }}
      {{ content.field_tags }}

The a-container div may only be displayed if the current user id is equals to the user id of the user linked to the profile that's being displayed.

I'd like to make this check in a preprocess function and return a bool 'is_current_user' to profile.html.twig but I'm stuggling to find the right hook for the profile page.

I'm on drupal 8.7.1.

Thanks in advance!


1 Answer 1


Found the answer in access the user associated with a profile.

It was simply THEME_preprocess_profile.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.