Unallow users to like/dislike their own posts

Go down

Unallow users to like/dislike their own posts Empty Unallow users to like/dislike their own posts

Post by mSyx June 27th 2020, 10:00 pm

Hey there,
After the announcement of the new Like and Dislike system nearly a week ago, I've seen some users wishing they could unallow users to like or dislike their own posts. This quite short JS code should do the job.

06/03 edit: Now removes only the like/dislike buttons and still shows the likes list.

Adding the JS:

Admin Panel » Modules » HTML & JAVASCRIPT: Javascript codes management; then, click on the CREATE A NEW JAVASCRIPT button.

Title * : As you wish.
Placement : In the topics
Javascript Code:


PHPBB2:
Code:
$(function() {
$('tr.post').each(function() {
var postauthor = $(this).find('td').first().find('.name').children().last().text();
var myname = _userdata.username;
 
if (postauthor === myname) { $(this).find('.fa_like_div button').remove(); }
}); });



PHPBB3:
Code:
$(function() {
$('div.post').each(function() {
var postauthor = $(this).find('.postprofile dl dt').children().last().text();
var myname = _userdata.username;

if (postauthor === myname) { $(this).find('.fa_like_div button').remove(); }
}); });



PUNBB:
Code:
$(function() {
$('div.post').each(function() {
var postauthor = $(this).find('.user-ident h4.username').children().last().text();
var myname = _userdata.username;
 
if (postauthor === myname) { $(this).find('.fa_like_div button').remove(); }
}); });



INVISION:
Code:
$(function() {
$('div.post').each(function() {
var postauthor = $(this).find('.postprofile .popmenubutton').children().last().text();
var myname = _userdata.username;
 
if (postauthor === myname) { $(this).find('.fa_like_div button').remove(); }
}); });



MODERNBB:
Code:
$(function() {
$('div.post').each(function() {
var postauthor = $(this).find('.postprofile .postprofile-name').children().last().text();
var myname = _userdata.username;
 
if (postauthor === myname) { $(this).find('.fa_like_div button').remove(); }
}); });



AWESOMEBB:
Code:
$(function() {
$('div.post-wrap').each(function() {
var postauthor = $(this).find('.post-aside .post-author-name').children().last().text();
var myname = _userdata.username;
 
if (postauthor === myname) { $(this).find('.fa_like_div button').remove(); }
}); });






Last edited by mSyx on March 6th 2021, 1:18 pm; edited 3 times in total
mSyx
mSyx
Forumember

Male Posts : 133
Reputation : 34
Language : French & English
Location : France

View user profile https://help.forumotion.com/

YoshiGM, Nefadar, SarkZKalie, TonnyKamper, trajce, mc nabulsy and tester101 like this post

Back to top Go down

Unallow users to like/dislike their own posts Empty Re: Unallow users to like/dislike their own posts

Post by jkh June 27th 2020, 11:00 pm

I've tried this code, but it didn't work for me.
jkh
jkh
Forumember

Posts : 579
Reputation : 17
Language : english

View user profile http://jillhavern.forumotion.net/

trajce likes this post

Back to top Go down

Unallow users to like/dislike their own posts Empty Re: Unallow users to like/dislike their own posts

Post by Ape June 28th 2020, 1:31 am

@jkh wrote:I've tried this code, but it didn't work for me.

Hello @jkh are you putting this in your JavaScript and putting all pages ?


Unallow users to like/dislike their own posts Left1212Unallow users to like/dislike their own posts Center11Unallow users to like/dislike their own posts Right112
Unallow users to like/dislike their own posts Ape_b110
Unallow users to like/dislike their own posts Keep_s10
Unallow users to like/dislike their own posts Ape1010
Ape
Ape
Administrator
Administrator

Male Posts : 16739
Reputation : 1812
Language : fluent in dork / mumbojumbo & English haha

View user profile http://chatworld.forumotion.co.uk/

jkh likes this post

Back to top Go down

Unallow users to like/dislike their own posts Empty Re: Unallow users to like/dislike their own posts

Post by mSyx June 28th 2020, 1:32 am

@jkh Hi,
Just tried on your forum, it seems to work for me.

Try this version ?:
Code:
$(function() {
$('div.post').each(function() {
var postauthor = $(this).find('.postprofile dl dt').children().last().text();
var myname = _userdata.username;
 
if (postauthor === myname) { $(this).find('.fa_like_div').remove(); }
}); });
mSyx
mSyx
Forumember

Male Posts : 133
Reputation : 34
Language : French & English
Location : France

View user profile https://help.forumotion.com/

jkh likes this post

Back to top Go down

Unallow users to like/dislike their own posts Empty Re: Unallow users to like/dislike their own posts

Post by jkh June 28th 2020, 7:21 am

@Ape - yes I did.

@mSyx Brilliant! That new one works much better, thank you.

Maybe it was because I'd tried it on my test forum rather than my main forum? But it works on both now.

How are you able to put a javascript on my forum?
jkh
jkh
Forumember

Posts : 579
Reputation : 17
Language : english

View user profile http://jillhavern.forumotion.net/

Back to top Go down

Unallow users to like/dislike their own posts Empty Re: Unallow users to like/dislike their own posts

Post by SLGray June 28th 2020, 7:26 am

It is not exactly placing it on your forum, but using the browser's console you can add CSS and scripts.


Unallow users to like/dislike their own posts Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 49318
Reputation : 3433
Language : English
Location : United States

View user profile https://forumsclub.com/gc/128-link-directory/

mSyx likes this post

Back to top Go down

Unallow users to like/dislike their own posts Empty Re: Unallow users to like/dislike their own posts

Post by jkh June 28th 2020, 7:45 am

I see thumleft 

Actually, I don't   Unallow users to like/dislike their own posts 1f602 

I should learn coding  Unallow users to like/dislike their own posts 1f631

It's taken me long enough to learn html when I'm editing blogger...it's all fun, and very interesting, though.
jkh
jkh
Forumember

Posts : 579
Reputation : 17
Language : english

View user profile http://jillhavern.forumotion.net/

pedxz likes this post

Back to top Go down

Unallow users to like/dislike their own posts Empty Re: Unallow users to like/dislike their own posts

Post by mSyx June 28th 2020, 6:27 pm

Thread updated with each version. Once again, any feedback is welcome I love you
mSyx
mSyx
Forumember

Male Posts : 133
Reputation : 34
Language : French & English
Location : France

View user profile https://help.forumotion.com/

Back to top Go down

Unallow users to like/dislike their own posts Empty Re: Unallow users to like/dislike their own posts

Post by tester101 August 20th 2020, 1:13 pm

hello guys can u fix the delay is a known issue during page refresh
we can still see the like and dislike buttons can we add the time based on during page refresh so we not see the buttons

and it seems to have a little bug i mean u cant see who have liked or dislike your own posts ?

@mSyx


Last edited by tester101 on August 20th 2020, 1:16 pm; edited 1 time in total
tester101
tester101
New Member

Posts : 1
Reputation : 1
Language : english

View user profile https://help.forumotion.com/t159201-unallow-users-to-like-dislik

Back to top Go down

Unallow users to like/dislike their own posts Empty Re: Unallow users to like/dislike their own posts

Post by YoshiGM August 20th 2020, 4:03 pm

I've tested you code in my forum and works very good!
Great job Bravo
YoshiGM
YoshiGM
Active Poster

Male Posts : 1098
Reputation : 132
Language : Spanish & English
Location : Mexico

View user profile http://asistencia.foroactivo.com/u21373

Back to top Go down

Unallow users to like/dislike their own posts Empty Re: Unallow users to like/dislike their own posts

Post by Simone Boi February 23rd 2021, 7:57 am

Hi! Thank for the tutorial, I've an issue to report, but I don't know if it's my fault or not.

I'm on ModernBB but if I use this code:

Code:
$(function() {
$('div.post').each(function() {
var postauthor = $(this).find('.postprofile .postprofile-name').children().last().text();
var myname = _userdata.username;
 
if (postauthor === myname) { $(this).find('.fa_like_div').remove(); }
}); });

Then I can't see my or others likes on my posts, so if an user gives me like i can't see that

While if I use this:

Code:
$(function() {
$('div.post').each(function() {
var postauthor = $(this).find('.postprofile dl dt').children().last().text();
var myname = _userdata.username;
 
if (postauthor === myname) { $(this).find('.fa_like_div').remove(); }
}); });

I can see other's likes but still I can like my own posts.



avatar
Simone Boi
Forumember

Posts : 65
Reputation : 1
Language : Italian

View user profile https://gamespledge.forumattivo.com/

Back to top Go down

Unallow users to like/dislike their own posts Empty Re: Unallow users to like/dislike their own posts

Post by mSyx March 6th 2021, 1:11 pm

Sorry for the late answers.

@tester101 wrote:hello guys can u fix the delay is a known issue during page refresh
we can still see the like and dislike buttons can we add the time based on during page refresh so we not see the buttons

and it seems to have a little bug i mean u cant see who have liked or dislike your own posts ?

@mSyx

Remove the current JS in the javascript modules.
In your viewtopic_body template, find:
Code:
<!-- END postrow -->

Put the following code right after:
Code:
<script type="text/javascript">
$('div.post').each(function() {
var postauthor = $(this).find('.postprofile .postprofile-name').children().last().text();
var myname = _userdata.username;
 
if (postauthor === myname) { $(this).find('.fa_like_div').remove(); }
});
</script>

@Simone Boi wrote:Hi! Thank for the tutorial, I've an issue to report, but I don't know if it's my fault or not.

I'm on ModernBB but if I use this code:

Code:
$(function() {
$('div.post').each(function() {
var postauthor = $(this).find('.postprofile .postprofile-name').children().last().text();
var myname = _userdata.username;
 
if (postauthor === myname) { $(this).find('.fa_like_div').remove(); }
}); });

Then I can't see my or others likes on my posts, so if an user gives me like i can't see that

While if I use this:

Code:
$(function() {
$('div.post').each(function() {
var postauthor = $(this).find('.postprofile dl dt').children().last().text();
var myname = _userdata.username;
 
if (postauthor === myname) { $(this).find('.fa_like_div').remove(); }
}); });

I can see other's likes but still I can like my own posts.

I can't reproduce the same thing. This may be linked to your templates modifications (if any).

EDIT

@tester101 wrote:and it seems to have a little bug i mean u cant see who have liked or dislike your own posts ?

True, didn't think about that. Working on it ~
Done, codes updated in the first post
mSyx
mSyx
Forumember

Male Posts : 133
Reputation : 34
Language : French & English
Location : France

View user profile https://help.forumotion.com/

TonnyKamper likes this post

Back to top Go down

Unallow users to like/dislike their own posts Empty Re: Unallow users to like/dislike their own posts

Post by Simone Boi March 7th 2021, 7:22 am

Thank you, now I can see likes, but I can still like my own post from mobile
avatar
Simone Boi
Forumember

Posts : 65
Reputation : 1
Language : Italian

View user profile https://gamespledge.forumattivo.com/

Back to top Go down

Unallow users to like/dislike their own posts Empty Re: Unallow users to like/dislike their own posts

Post by mSyx March 7th 2021, 10:19 am

@Simone Boi wrote:Thank you, now I can see likes, but I can still like my own post from mobile

That is because mobile & web templates are different. I'll try doing the same for the mobile version soon enough. I love you
mSyx
mSyx
Forumember

Male Posts : 133
Reputation : 34
Language : French & English
Location : France

View user profile https://help.forumotion.com/

Simone Boi likes this post

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum