2

Drupal 7 has a "personalization" section on ...admin/config/people/accounts

If this exists in Drupal 9, I'd love to know where it is. The goal: enable signatures for user accounts.

If it's truly gone in D9, the question then becomes what's the best workaround?

  • A custom field in user account: then how to display that in the comment?
  • Is there a module I haven't found that does this? I see a signatures module but it appears underdeveloped and lacks the security OK.

2 Answers 2

3

git log -Spersonalization led me to https://www.drupal.org/node/1548204, which leads to https://www.drupal.org/project/signature and https://www.drupal.org/node/2457545. So, this feature was moved to contrib before Drupal 8 launched in 2015 and this functionality is now in the Signature module.

1
  • Not the answer I was hoping for, but it is the answer. Thanks.
    – aharown07
    Commented Sep 20, 2022 at 0:42
-1

Custom field + twig solution: It is also possible to use a combination of custom field in 'user' and then print in comments.html.twig

[edit to add version that does not use '|raw']

{{- content|without('links') -}}  {# suppress links #}
    {# add sig #}
    <div class="usersig">
     {% set usersig = comment.getOwner.YOUR_FIELDNAME.value %}
            {%  if usersig|length == 0 %}
              {% set usersig = ' ' %}
            {%  endif %}
              {% set sigbody = {
                  '#type':   'processed_text',
                  '#text':    usersig,
                  '#format':  comment.getOwner.YOUR_FIELDNAME.format,
                } %}
              {{sigbody}}
    </div>
    {# add previously suppressed links #}
   {{content.links}}

[end edit]

Original method (probably not a good idea)...

{{ comment.getOwner.INSERT_CUSTOM_FIELDNAME.value|raw }}    

The "|raw" is for formatted text field (renders the html as html). If your field is plain text omit that.

The advantage of this approach is that it is lighter and does not depend on a module that is not ready for production use. Disadvantage: the module appears to offer some more features.

On the safety of the |raw switch - One method is to use the Twig Tweak module's check_markup feature. That and other options discussed here: How to print text (formatted, long) in twig without raw filter?

6
  • |raw is usually unsafe.
    – mona lisa
    Commented Nov 29, 2022 at 23:38
  • Thanks. Will have to fix that. Would it be unsafe if the field is limited to a trusted role and has limited html for its filter? If so, what's best practice for rendering the field safely? I should note that I got that option from here: drupal.org/docs/8/modules/inline-formatter-field/… If it's unsafe, perhaps the documentation needs updating?
    – aharown07
    Commented Nov 30, 2022 at 0:17
  • Yes, that is probably a bad example. Official docs on the subject are: drupal.org/docs/security-in-drupal/…
    – mona lisa
    Commented Nov 30, 2022 at 0:39
  • Found some info on that. Editing the answer.
    – aharown07
    Commented Nov 30, 2022 at 0:39
  • Added method that does not use '|raw' filter.
    – aharown07
    Commented Nov 30, 2022 at 2:29

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.