The effects of alcohol on sustanon 250 leucine for – real weight loss & bodybuilding benefits?
How can I change su...
 
Share:
Notifications
Clear all

Question [Solved] How can I change subscribers name to full name?

2 Posts
2 Users
0 Reactions
58 Views
Posts: 1
Topic starter
(@herby65)
New Member
Joined: 2 weeks ago

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));
        }
    });
});
1 Reply
Asti
Posts: 7789
 Asti
Support
(@asti)
Illustrious Member
Joined: 7 years ago

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/

Reply
Share: