Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Delete profile picture in confluence 5.8

Lukas Knoch -Rumpelcoders-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 7, 2015

Hi,

is it possible to delete your own/some one else 's (as admin) profile picture in confluence 5.8?

If it's not possible via the ui, can it be done from java api?

Best regards, Lukas

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
xpauls
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 8, 2015

Java class

public class RemoveProfilePicture extends HttpServlet {
    private String user;
    private UserAccessor userAccessor;
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //only make it usable by administrators
        if (userAccessor.hasMembership(userAccessor.getGroup("confluence-administrators"), AuthenticatedUserThreadLocal.get())) {
            user = request.getParameter("user");
            ConfluenceUser confUser = userAccessor.getUserByName(user);
            if (confUser != null) {
                userAccessor.getPropertySet(confUser).remove(UserPreferencesKeys.PROPERTY_USER_PROFILE_PICTURE);
                response.getWriter().append("Profile pic removed for user: " + user);
            } else
                response.getWriter().append("No such user: " + user);
        } else
            response.getWriter().append("No permission");
    }
    public void setUserAccessor(UserAccessor userAccessor) {
        this.userAccessor = userAccessor;
    }
    public void setUser(String user) {
        this.user = user;
    }
}

Add this to atlassian-plugin.xml

<servlet key="remove-pic-servlet" class="com.tieto.plugins.utilities.RemoveProfilePicture"
        name="Remove profile pic servlet">
        <url-pattern>/custom/removeProfilePicture</url-pattern>
    </servlet>

Of course, replace class with your class name. You can also change url pattern if you wish.

 

Access it with this url: /plugins/servlet/custom/removeProfilePicture?user=username , where username is actual username.

Lukas Knoch -Rumpelcoders-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 8, 2015

Thanks a lot, just what i was looking for. :)

0 votes
Lukas Knoch -Rumpelcoders-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 7, 2015

Yes i am. Could you send me some sample code? That would be great.

0 votes
xpauls
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 7, 2015

You can write a servlet plugin which would do that. Are you familiar with writing plugins in confluence?

TAGS
AUG Leaders

Atlassian Community Events