The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Unallow users to like/dislike their own posts

+4
SLGray
Ape
jkh
mSyx
8 posters

Go down

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

Post by mSyx Sat 27 Jun 2020 - 22:00

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:



PHPBB3:



PUNBB:



INVISION:



MODERNBB:



AWESOMEBB:






Last edited by mSyx on Sat 6 Mar 2021 - 13:18; edited 3 times in total
mSyx
mSyx
Forumember

Male Posts : 155
Reputation : 47
Language : French & English
Location : France

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 Sat 27 Jun 2020 - 23:00

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

Posts : 620
Reputation : 17
Language : english

http://jillhavern.forumotion.net/

sivastar and trajce 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 Ape Sun 28 Jun 2020 - 1:31

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 Ape1010
Ape
Ape
Administrator
Administrator

Male Posts : 19110
Reputation : 1991
Language : fluent in dork / mumbojumbo & English haha

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 Sun 28 Jun 2020 - 1:32

@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 : 155
Reputation : 47
Language : French & English
Location : France

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 Sun 28 Jun 2020 - 7:21

@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 : 620
Reputation : 17
Language : english

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 Sun 28 Jun 2020 - 7:26

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 : 51482
Reputation : 3519
Language : English
Location : United States

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 Sun 28 Jun 2020 - 7:45

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 : 620
Reputation : 17
Language : english

http://jillhavern.forumotion.net/

tikky 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 Sun 28 Jun 2020 - 18:27

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

Male Posts : 155
Reputation : 47
Language : French & English
Location : France

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 Thu 20 Aug 2020 - 13:13

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 Thu 20 Aug 2020 - 13:16; edited 1 time in total
tester101
tester101
New Member

Posts : 1
Reputation : 1
Language : english

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 Thu 20 Aug 2020 - 16:03

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

Male Posts : 1499
Reputation : 144
Language : Spanish & English
Location : Mexico

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 Tue 23 Feb 2021 - 7:57

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 : 92
Reputation : 2
Language : Italian

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 Sat 6 Mar 2021 - 13:11

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 : 155
Reputation : 47
Language : French & English
Location : France

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 Sun 7 Mar 2021 - 7:22

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

Posts : 92
Reputation : 2
Language : Italian

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 Sun 7 Mar 2021 - 10:19

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 : 155
Reputation : 47
Language : French & English
Location : France

https://help.forumotion.com/

Simone Boi 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 Guest Mon 16 Jan 2023 - 0:43

I would like to do an update for this tutorial. Instead of separating scripts for each version, I modified script to make only one script for all forum versions where version is selected automatically.

Code:
$(document).ready(function() {

    const FORUM_VERSION = _userdata["tpl_used"];

    var versions = {
        'subsilver': $('tr.post'),
        'prosilver': $('div.post'),
        'punbb': $('div.post'),
        'invision': $('div.post'),
        'modernbb': $('div.post'),
        'awesomebb': $('div.post-wrap')
    };

    var versionFind = {
        'prosilver': '.postprofile dl dt',
        'punbb': '.user-ident h4.username',
        'invision': '.postprofile .popmenubutton',
        'modernbb': '.postprofile .postprofile-name',
        'awesomebb': '.post-aside .post-author-name'
    };



    versions[FORUM_VERSION].each(function() {
        var myname = _userdata.username;

        if (FORUM_VERSION == "subsilver") {
            var postauthor = $(this).find('td').first().find('.name').children().last().text();
            if (postauthor === myname) {
                $(this).find('.fa_like_div button').remove();
            }
            return;
        }

        var postauthor = $(this).find(versionFind[FORUM_VERSION]).children().last().text();
        if (postauthor === myname) {
            $(this).find('.fa_like_div button').remove();
        }

    });

});


Last edited by System32 on Mon 16 Jan 2023 - 10:36; edited 2 times in total
avatar
Guest
Guest


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 brandon_g Mon 16 Jan 2023 - 4:49

System32 wrote:I would like to do an update for this tutorial. Instead of separating scripts for each version, I modified script to make only one script for all forum versions where version is selected automatically.

Code:
$(document).ready(function() {

    const FORUM_VERSION = _userdata["tpl_used"];

    var versions = {
        'subsilver': $('tr.post'),
        'prosilver': $('div.post'),
        'punbb': $('div.post'),
        'invision': $('div.post'),
        'modernbb': $('div.post'),
        'awesomebb': $('div.post-wrap')
    };

    var versionFind = {
        'prosilver': '.postprofile dl dt',
        'punbb': '.user-ident h4.username',
        'invision': '.postprofile .popmenubutton',
        'modernbb': '.postprofile .postprofile-name',
        'awesomebb': '.post-aside .post-author-name'
    };



    versions[FORUM_VERSION].each(function() {
        var myname = _userdata.username;

        if (FORUM_VERSION == "subsilver") {
            var postauthor = $(this).find('td').first().find('.name').children().last().text();
            if (postauthor === myname) {
                $(this).find('.fa_like_div button').remove();
            }
        }

        var postauthor = $(this).find(versionFind[FORUM_VERSION]).children().last().text();
        if (postauthor === myname) {
            $(this).find('.fa_like_div button').remove();
        }

    });

});

That is some pretty nice code there @System32, clever use of a key/value dictionary Very Happy. Have you tested this on all versions already?


Unallow users to like/dislike their own posts Brando10
Remember to mark your topic Unallow users to like/dislike their own posts Solved15 when a solution is found.
General Rules | Tips & Tricks | FAQ | Forgot Founder Password?

Unallow users to like/dislike their own posts Scre1476
Team Leader
Review Section Rules | Request A Review | Sticker Points
brandon_g
brandon_g
Manager
Manager

Male Posts : 10106
Reputation : 923
Language : English
Location : USA

https://www.broadcastingduo.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 Guest Mon 16 Jan 2023 - 10:13

Yes, I have. Razz
And thanks. I always use that to adapt script for all versions Wink

Script edited. I added return statement for phpBB2. Missed it.
avatar
Guest
Guest


Back to top Go down

Back to top

- Similar topics

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