How can I add new action/feature to questions and answers?

4.75K viewsGeneral
0

I would like to add “Like” functionality to questions and answers so that users can like other user’s questions and answers. How can this be achieved?

0

I agree with @Dima. There is no need of additional like system. You can easily turn voting button to like button. There is an option in AnsPress to hide down vote, do it and add some CSS.

We want to add Like functionality in addition to the Upvote functionality. So that people will be able to Like Post without giving any points as well as upvote to give points

I want to mimic the upvotes logic to implement Like functionality, which hooks/action should I use? (I couldn’t find a hook to add custom action/features).

1

You would need to write custom PHP code to achieve this.

It will be pretty simple, just mimic the upvotes logic.

(are you sure you want to add another likes system? there is already “likes” and “dislikes”, the thumbsup and thumbsdown icons near the number)

Which hooks/action should I use if I want to mimic the upvotes logic? (I couldn’t find a hook to add custom action/features).

Me answering this question would mean me do the development. Hire me at 25$/hour, I’ll do it no problem.

I can tell you the steps you will probably need to walk in order to implement it:
– look at the “upvote” button. Make a new button near it with it’s own id/class. Duplicate the JS of upvote button to your button.
– look what that JS calls, duplicate it in your code.
– look where it stores the data, store your data same way in your code.
– look how and where upvotes data is displayed, implement methods to get your custom meta in the same way.
– find a good place to put your custom code. Most likely, template override and a code snippet will be enough. Could do a plugin.
– you are done, congratulations! Now you may repeat this process of reverse engineering to display your likes data in profiles as well.

TL;DR: there is no simple “hook” to do it in one line. A usual process of developing a feature should be done.