How to reset All Likes in a page

Still need help?

The Atlassian Community is here for you.

Ask the community

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:

  1. Go to  > General Configuration > User Macros.
  2. Choose Create a User Macro.
  3. Enter the Macro Name
  4. 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)
  5. Save the Macro
  6. 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

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.