Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rubinho 30 posts 218 karma points
    Feb 20, 2016 @ 19:22
    Rubinho
    0

    Save Groups (roles) of members in Examine

    Hi,

    I'm extending the Examine content when saving members and need to save the roles of the member in Examine to perform fast membersearches.

    There are 2 roles i need to index:

    private void IndexCustomMemberData(object sender, IndexingNodeDataEventArgs e)
    {
        var memberservice = ApplicationContext.Current.Services.MemberService;
        var thisMember = memberservice.GetById(int.Parse(e.Fields["id"]));
        var groups = System.Web.Security.Roles.GetRolesForUser(thisMember.Username);
        var isGroupA = groups.Contains("GroupA");
        var isGroupB = groups.Contains("GroupB");
        e.Fields.Add("GroupA", isGroupA ? "1" : "0");
        e.Fields.Add("GroupB", isGroupB ? "1" : "0");
    }
    

    The problem is that de groups variable contains the groups from before the save method. If a add a group to a member, after the first Save, the group will not be added, only from the second save.

    Any idea how i can get this newly assigned groups immediately?

    Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft