Feb 07, 2025 2:43 pm
Our website uses the comment function exclusively in the members area.
When someone makes a comment, I would like to see the full name. Often the users have abbreviations that make it difficult to immediately identify who they are. I have already tried various methods, but none of them work.
The subscriber name (or author name) should be replaced by First / Lastname.
I had the script developed, but it works.
Maybe it is much simpler.
Where can I find the code to swap the names?
Who can help?
Β
document.addEventListener('DOMContentLoaded', function () { // Warte, bis die Seite vollstΓ€ndig geladen ist var commentAuthors = document.querySelectorAll('#wpdcom .wpd-comment-header .wpd-comment-author'); commentAuthors.forEach(function(authorElement) { var userId = authorElement.getAttribute('data-user-id'); // Benutzer-ID holen if (userId) { // Benutzerdaten abrufen (Vorname, Nachname) fetch('/wp-json/wp/v2/users/' + userId) .then(response => response.json()) .then(user => { var firstName = user.first_name; var lastName = user.last_name; var fullName = firstName + ' ' + lastName; // Den Kommentatorennamen ersetzen authorElement.textContent = fullName; }) .catch(error => console.error('Fehler beim Abrufen des Benutzernamens:', error)); } }); });
Website URL
1 Reply
Feb 08, 2025 9:50 am
Hi,
You should change the "Display name publicly as" option value. The following article should help you with this: https://memberfix.rocks/change-display-name-publicly-as/