Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Change blog author
I need to change the author on several published blog posts. Is there a way to do that without entirely re-entering/re-publishing the blog post?
Hi Kristin,
Not sure if you thought about the approach to solve it programmatically - one way would be to use Actionable Dynamic Query.
In case, you go with this approach - use the setAddCriteriaMethod to retrieve the blog list that needs an author update and then use setPerformActionMethod to update the Author details.
Here is how I used it to solve a similar issue related to the Layout entity.
private void updateLayouts() throws Exception {
ActionableDynamicQuery adq = _layoutLocalService.getActionableDynamicQuery();
adq.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<Layout>() {
@Override
public void performAction(Layout layout) {
try {
// put the update logic here
} catch (PortalException e) {
log.error(e);
}
}
});
try {
adq.performActions();
} catch (Exception e) {
log.error(e);
}
}
@Reference(unbind = "-")
LayoutLocalService _layoutLocalService;
Here is a link that describes more about Actionable Dynamic Query -
For programmatic approaches, I'd look at the anonymization code, that replaces the original author with an anonymous user before deleting the actual author's user account.