This project is read-only.
1
Vote

Projection filters ignore user content items when filtered on profile fields

description

If you have a projection showing a list of users and filter it based on a profile field. Then a user will not appear in the list till an admin saves the user in the admin.

I found changing the EditPost method to use ContentManager to get and publish publish the user content item fixed this:
public ActionResult EditPost() {
    if (Services.WorkContext.CurrentUser == null) {
        return HttpNotFound();
    }

    var userId = Services.WorkContext.CurrentUser.Id;
    var user = Services.ContentManager.Get<UserPart>(userId, VersionOptions.DraftRequired);

    dynamic shape = Services.ContentManager.UpdateEditor(user.ContentItem, this);
    if (!ModelState.IsValid) {
        Services.TransactionManager.Cancel();
        return View("Edit", (object)shape);
    }

    Services.ContentManager.Publish(user.ContentItem);
    Services.Notifier.Information(T("Your profile has been saved."));

    return RedirectToAction("Edit");
}

comments