Notifications
Clear all

Author NAME to NICKNAME in Discuz pligin for WP

11 Posts
2 Users
1 Reactions
4,405 Views
(@trialex2015)
Active Member
Joined: 9 years ago
Posts: 6
Topic starter  

Hi. I'm trying to change author NAME to author NICKNAME in Discuz pligin for WP. But can't find how to do this. Help. plz?

THX.

Alexander


   
Quote
 Tom
(@tomson)
Famed Member Admin
Joined: 10 years ago
Posts: 4214
 

Hi trialex2015,

Please put this in current active functions.php file:

add_filter('wpdiscuz_comment_author', 'wpdiscuz_my_author', 10, 2);
function wpdiscuz_my_author($author_name, $comment) {
    if ($comment->user_id) {
        $column = 'nickname'; // Other options: 'user_login', 'user_nicename', 'nickname', 'first_name', 'last_name'
        $author_name = get_the_author_meta($column, $comment->user_id);
    }
    return $author_name;
}

   
ReplyQuote
(@trialex2015)
Active Member
Joined: 9 years ago
Posts: 6
Topic starter  

Where is it?


   
ReplyQuote
 Tom
(@tomson)
Famed Member Admin
Joined: 10 years ago
Posts: 4214
 

You should put this code in your current active functions.php file


   
ReplyQuote
(@trialex2015)
Active Member
Joined: 9 years ago
Posts: 6
Topic starter  

Now it is not any name at all 🙁

1 - talking about this field.

2 - i delete it myself, it's ok here.

 

Screenshot wpd username

   
ReplyQuote
 Tom
(@tomson)
Famed Member Admin
Joined: 10 years ago
Posts: 4214
 

Then change

$column = 'nickname';

to

$column = 'user_nicename';

   
ReplyQuote
(@trialex2015)
Active Member
Joined: 9 years ago
Posts: 6
Topic starter  

Nothing changes. I need print this filed (wp db)

Screenshot wpd username2

   
ReplyQuote
 Tom
(@tomson)
Famed Member Admin
Joined: 10 years ago
Posts: 4214
 

I've already provide with the only solution, it seems something is wrong on your end. Maybe you test with a comment author who doesn't have such data in database.  Please try to play around that code, there is not other way by now.


   
ReplyQuote
(@trialex2015)
Active Member
Joined: 9 years ago
Posts: 6
Topic starter  

BuddyPress, m/b? 😮


   
ReplyQuote
(@trialex2015)
Active Member
Joined: 9 years ago
Posts: 6
Topic starter  

OK, i fix a bug. From your message:

add_filter('wpdiscuz_comment_author', 'wpdiscuz_my_author', 10, 2);
function wpdiscuz_my_author($author_name, $comment) {
    if ($comment->user_id) {
        $column = 'nickname'; // Other options: 'user_login', 'user_nicename', 'nickname', 'first_name', 'last_name'
            $author_name = get_the_author_meta($column, $comment->user_id);
        }
    }
    return $author_name;
}

This is unexpected "}" on line 6. 

Now, it's all clear. THX!

 

 


   
Tom reacted
ReplyQuote
 Tom
(@tomson)
Famed Member Admin
Joined: 10 years ago
Posts: 4214
 

Ah, Great!

Thank you very much for sharing this, I'll edit right away.

 


   
ReplyQuote
Share:
Scroll to top