Notifications
Clear all

Paid Addons Support Forum Only

Please note, that here we only support Paid Addons issues and questions.

gVectors Support staff works from 6am to 6pm (GMT+0)

All questions related to wpForo and wpDiscuz free plugins should be asked in the corresponding plugin support forum:

 

wpDiscuz Support Forum wpForo Support Forum

[Solved] Author Info Popup needed on Author Name as well as Author Image Link


Om Swami Meditations
Posts: 9
Customer
Topic starter
(@om-swami-meditations)
Member
Joined: 2 months ago

Dear Wp Discuz Team - Thanks for the wonderful plugin & add-ons that you have built. They are well written & very fast which is great. I had a question around "Comment Author Info" add-on.

As shown on this demo - https://addons.wpdiscuz.com/wpdiscuz-comment-author-info/. The add-on adds different type of links on Author's Avatar Image & Name. Author's Avatar Image is a link the the Author's page while Author's Name is the popup provided by Comment Author Info Add-on.

We want both the Author's Avatar Image & Name to launch the Comment Author Info Add-on. That way if the user really needs more details on the Author, they can click on Author's name but the behavior on both avatar image click & name click should be same/consistent IMHO.

Kindly let me know, how this can be achieved.

Regards

5 Replies
Elvina
Posts: 1407
Moderator
(@elvina)
Noble Member
Joined: 1 year ago

Hi @om-swami-meditations,

Please follow the steps below to make it work as you want:

1. Put the following JS code in the current active theme JS file:

jQuery(document).ready(function ($) {
$('.wpd-comment-author').addClass('wcai-short-info wcai-not-clicked');
if (typeof wpdiscuzAjaxObj !== 'undefined') {
wpdiscuzAjaxObj.addClassOnAuthorName = function () {
$('.wpd-comment-author').addClass('wcai-short-info wcai-not-clicked');
};
}
});

Here is a good example on how to add JS code:  https://www.wpbeginner.com/wp-tutorials/how-to-easily-add-javascript-in-wordpress-pages-or-posts/

2. Put the following hook in the current active functions.php file:

add_filter("wpdiscuz_ajax_callbacks", function ($response) {
$response["callbackFunctions"][] = "addClassOnAuthorName";
return $response;
});

3. Save, delete all caches, and check again.

Om Swami Meditations
Posts: 9
Customer
Topic starter
(@om-swami-meditations)
Member
Joined: 2 months ago

Thank you @Elvina for the suggestions. I tried the steps as you suggested but it did not work the way I was expecting. Few things that I noticed are:

  1. The code is adding a class to wpd-comment-author class, while I wanted to modify the avatar behavior. It seems like the code is modifying comment author behavior.
  2. The hook also seems to be adding class to Author Name & Author Avatar.

Just to repeat my question, Comment Author name link is launching the "Comment Author Info" popup & that is the correct behavior. I don't want to make any change to that behavior.

But Comment Author Avatar is a hyperlink to Author's Page. This is the behavior, I want to change where clicking on Comment Author Avatar should also launch "Comment Author Info" popup. Can you please recheck & confirm the solution?

Regards

Om Swami Meditations
Posts: 9
Customer
Topic starter
(@om-swami-meditations)
Member
Joined: 2 months ago

Hi @Elvina - Do you have an update on this ticket?

1 Reply
Astghik
Admin
(@astghik)
Joined: 3 years ago

Support Team
Posts: 4787

@om-swami-meditations,

I apologize for the late response. Please follow the steps below:

1. Remove the code from the functions.php file. It's not necessary. 

2. Replace the js code provided by Elvina with the following one:

jQuery(document).ready(function ($) {
$(document).on('click', '.wcai-short-info', function (e) {
e.preventDefault();
var elem = $(this);
elem.removeClass('wcai-not-clicked');
var attrId = elem.parents('.wpd-comment-left').siblings('.wpd-comment-right').attr('id');
var commentId = attrId.substring(attrId.lastIndexOf('-') + 1);
var data = new FormData();
data.append('commentId', commentId);
data.append('action', 'wcaiGetInfo');
wpdiscuzAjaxObj.getAjaxObj(true, true, data).done(function (resp) {
elem.addClass('wcai-not-clicked');
if (resp) {
$('#wcaiInfo').html(resp);
$('#wcaiInfo ul.wcai-list .wcai-list-item:first-child').addClass('wcai-active');
$('#wcaiInfo div.wcai-content .wcai-content-item:first-child').addClass('wcai-active'); if (!($('#wcaiInfo').is(':visible'))) {
$('#wcaiInfoAnchor').trigger('click');
}
}
$('#wpdiscuz-loading-bar').hide();
});
return false;
});
});
Om Swami Meditations
Posts: 9
Customer
Topic starter
(@om-swami-meditations)
Member
Joined: 2 months ago

Thank you very much. This worked.

Share:
Scroll to top