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

Limited Support

Our team is currently on holiday, so support will be limited during this period. Response times may be slower than usual, and some inquiries may be delayed.
We appreciate your patience and understanding, and we’ll resume our usual support by the end of August.

 

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

2 Posts
2 Users
0 Reactions
274 Views
Posts: 1
Topic starter
(@herby65)
New Member
Joined: 6 months 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: 8075
 Asti
Support
(@asti)
Illustrious Member
Joined: 8 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: