Block Self Reactions
I've been working on and created a PHP code snippet to block self likes/reacts by a user on their own posts/comments. This triggers a warning notice using FCom's built in system.
Here's a quick video I did to show it. It will give two different messages depending on what you're attempting to self like. So either "You cannot like your own post" or "You cannot like your own comment".
https://share.jeffbrigman.com/Jru9NY25
You can get the code for free at my community: https://jeffbrigman.com/community/
And if you feel so inclined: https://buymeacoffee.com/jeffbrigman
This should be core function imo.
Drive ZoneΒ I would prefer an option in leaderboard settings for either or.
Drive ZoneΒ but that is not how the system works π
for individual feed's comment, a filter hook has been provided,
apply_filters('fluent_community/disable_self_comment_react', false, $feed)
Tawsif Ahmed RiyadΒ what about whole post? I would like to have self-reactions blocked on everything to prevent points hunt from users. It can also show error message something line "You can not react on your own post." Make it as core function to let community admins choose if they want to apply this function or not.
Tawsif Ahmed RiyadΒ yes, they have the apply filters for both comments and posts coded in, but neither work. Even if you overwrite the core code to true, it still lets you like your own content.
This tells me they are planning for a future feature release for this, but for now it's not working.
Here's the file path: fluent-community/app/Http/Controllers/CommentsController.php
Line 411 for posts
Line 524 for comments
Jeff BrigmanΒ Thanks for posting the code. So far works nicely. However, I found that you can not see who liked your posts or comments, when you try to see the likes on your posts. As soon as you hit "click to view" your likes, you get the message "Failed to Load the List" followed by the pop up error message that you can't like your own post.
arjun arjunΒ I was able to replicate and found another issue, and I think I have fixed both. I have updated the original post with the updated version.
Jeff BrigmanΒ Great Jeff! You have done it very well this time...reduced the lines of code as well...and it is working perfectly...Much appreciate you sharing such useful code snippets this way for the whole community.
Updated the code to fix the issue arjun arjunΒ found, the one I found and in the process discovered another bug that's on the FC dev side and reported it.
This is golden!
Brilliant ππ
Jeff BrigmanΒ today I noticed that your snippet also blocks bookmarking your own post which I think is a pity. Sometime I save my post too.
Drive ZoneΒ Iβll list it as a known issue and come back to it for review.
Jeff BrigmanΒ Thank you for your notice Jeff. You are doing a wonderful job helping people enhance their sites in the community through your snippets.
Drive ZoneΒ Fixed. Blocks Self Reactions (Posts & Comments) while allowing self bookmarking.