AI Assistant
Notifications
Clear all

Remove link from mentioned username in comment

6 Posts
3 Users
0 Reactions
2,494 Views
Posts: 14
Customer
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@devin)
Member
Joined: 9 years ago
[#3471]

Hi wpDiscuz Team,

Can you tell me how I can remove the link from the username that appears when a user is mentioned in a comment? Here's an example on my page  https://countryguitaronline.com/worried-blues-guitar-lesson/#comment-4017126

The reason I'd like to remove the link is because all of the members on my website are Subscribers and not Editors or Admin so they don't have any posts. When I click the link of the wpDiscuz mentioned user in the comment, it goes to a blank page with zero posts by that Subscriber.

Thanks for your help! I'm still really loving the plugin.

Devin


5 Replies
Astghik
Posts: 6645
Admin
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@astgh)
Illustrious Member
Joined: 8 years ago

Hi @devin,

I'm sorry, but there is no option for this purpose. You should add this js code in your current active theme's js file, it'll remove the link from the mentioned username:

jQuery.each(jQuery('.hint'), function () {
var txt = jQuery(this).html();
var cls = jQuery(this).attr('class');
var data = jQuery(this).attr('data-ucm_user_id');
jQuery(this).replaceWith(jQuery('<span></span>').attr('class', cls).attr('data-ucm_user_id', data).html(txt))
});

Reply
Posts: 8
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@davehamilton)
Active Member
Joined: 8 years ago

Is this still the best/only solution here? We were hoping that maybe a hook had been added so we could write an override function to keep it from ever being passed in the HTML in the first place.

Thanks!


Reply
3 Replies
Astghik
Admin
(@astgh)
Joined: 8 years ago

Illustrious Member
Posts: 6645
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

yes @davehamilton, you'll need to use this solution. No other we can provide you. 

 


Reply
(@davehamilton)
Joined: 8 years ago

Active Member
Posts: 8
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@astghik Thanks for the note. We actually spent some time last night coding and came up with an even better workaround. 

The problem with the aforementioned JavaScript override is that it still puts the href link in the HTML source, and since the JavaScript doesn't hide it from Google we were still were getting dinged for broken links to these non-existent author pages.

To solve this, we created a custom function in our custom plugin that hooks into the Wordpress the_author_link() function and clears it from there.

Works perfectly, and completely eliminates this mess for us. You might need to modify this based upon your custom plugin's functionality as it relates to authors, but edit_posts was a perfect "litmus test" for us here.

function our_custom_author_link( $link, $author_id, $author_nicename ) {

if ( !user_can( $author_id, 'edit_posts' ) ) {
return '';
}
// Otherwise, return $link unmodified
return $link;
}
add_filter( 'author_link', 'our_custom_author_link', 10 , 3 );

Reply
Astghik
Admin
(@astgh)
Joined: 8 years ago

Illustrious Member
Posts: 6645
Astghik
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

Thank you @davehamilton!

Yes, we'll make those changes in the plugin core. 


Reply
Share:
Scroll to top