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
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; }
Where is it?
You should put this code in your current active functions.php file
Then change
$column = 'nickname';
to
$column = 'user_nicename';
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.
BuddyPress, m/b? 😮
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!
Ah, Great!
Thank you very much for sharing this, I'll edit right away.