How to reset All Likes in a page
Description
This user macro will reset all the likes in a page. Just embed it in a page temporarily (using one of the preview modes should be enough) and it should remove all likes on that page.
Option 1:
Applicable for Confluence 6.x.
Create a user macro with the following steps:
- Go to > General Configuration > User Macros.
- Choose Create a User Macro.
- Enter the Macro Name
Add the following Parameter in Template:
## @noparams #set($containerManagerClass=$content.class.forName('com.atlassian.spring.container.ContainerManager')) #set($getInstanceMethod=$containerManagerClass.getDeclaredMethod('getInstance',null)) #set($containerManager=$getInstanceMethod.invoke(null,null)) #set($containerContext=$containerManager.containerContext) #set($likeManager=$containerContext.getComponent('likeManager')) $likeManager.removeAllLikesOn($content)
- Save the Macro
- Add the macro in the page.
Option 2:
The above user macro stopped working for Confluence 7.x as the code has been deprecated. However you can reset the likes on the page from the database directly.
Please note Atlassian support not support directly editing the DB, but if you wish to proceed you may use the below queries at your own risk. Please ensure to take a backup of your database before making any changes.
There is a table called likes where such information are stored. If you just need to remove the entry from that table for specific page.
To delete:
- If you know the page ID you can simply remove that:
DELETE FROM likes
WHERE contentid = <PAGEID>;
- Or to choose the page title you could use following - remember to substitute page title:
DELETE From likes
WHERE contentid = (SELECT contentid FROM content WHERE prevver is NULL and title='<Page Title>');
If you have same title of the page in the different space this will not work and you need to check the exact page id (content id)
Last modified on Aug 18, 2020
Powered by Confluence and Scroll Viewport.