The effects of alcohol on sustanon 250 leucine for – real weight loss & bodybuilding benefits?
wpdiscuz_comment_au...
 
Share:
Notifications
Clear all

[Solved] wpdiscuz_comment_author Filter does not fire

6 Posts
2 Users
1 Reactions
747 Views
Posts: 9
Topic starter
(@serveracademy)
Active Member
Joined: 3 years ago

I have tried implementing this example provided for changing the displayed name for a comment:

https://wpdiscuz.com/docs/codex/filters/wpdiscuz_comment_author/

I changed the code to remove the if statement:

add_filter("wpdiscuz_comment_author", function ($authorName, $comment) {
    $authorName = "Boss";
    return $authorName;
}, 10, 2);

However this still does not change any displayed author names:

image

I added the "wpdiscuz_after_comment_author" filter and that works perfectly. Please help!

 

5 Replies
Asti
Posts: 7661
 Asti
Support
(@asti)
Illustrious Member
Joined: 7 years ago

Hi @serveracademy,

Please navigate to Dashboard > wpDiscuz > Settings > General Settings tab, and delete the wpDiscuz caches using the "

Also, don't forget to press Ctrl+F5 (twice) on the frontend before checking.

1 Reply
(@serveracademy)
Joined: 3 years ago

Active Member
Posts: 9

@asti I was writing my reply below before I read this comment. I undid my work and purged the user cache like you mentioned and it worked!

image

It would be amazing if we could add comments to the docs codex or if this could be noted there.

Posts: 9
Topic starter
(@serveracademy)
Active Member
Joined: 3 years ago

EDIT: DISREGARD THIS REPLY AND SEE ABOVE SOLUTION FOR PURGING CACHE

After inspecting the plugin code, I found the filter is ONLY firing for comment replies:

image

I believe this filter should be applied to base comments as well. After reading this documentation linked below I decided to edit the template and add support for the filter myself.

For anyone else following behind me, this documentation is a bit outdated as well because I could not locate the CSS file at '/wpdiscuz/assets/css/wpdiscuz.css', but thankfully I did not need it.

https://wpdiscuz.com/docs/wpdiscuz-documentation/customization/custom-template-and-style/

I copied 'class.WpdiscuzWalker.php' into my child theme folder (/wp-content/themes/mytheme/wpdiscuz/', and around line 254 I added the following code:

        $uNameClasses = apply_filters("wpdiscuz_username_classes", "");
        $user["authorNameHtml"] = '<div class="wpd-comment-author" style="padding: 0px;">' . apply_filters("wpdiscuz_comment_author", $user["user"]->data->display_name, $comment) . '</div>';
        $user["authorNameHtml"] .= apply_filters("wpdiscuz_after_comment_author", "", $comment, $user["user"]);

Now the author name I configured in the filtered function is displaying as desired. Again, I believe this should be included by default and I believe this is a bug.

2 Replies
Asti
 Asti
Support
(@asti)
Joined: 7 years ago

Illustrious Member
Posts: 7661

@serveracademy,

Please watch this video:  https://www.screencast.com/t/MHItBGTip

The hook code works fine. 

(@serveracademy)
Joined: 3 years ago

Active Member
Posts: 9

@asti Fantastic, thank you! It would be amazing if we could add comments to the docs codex or if this could be noted there.

Share: