Sort the search results on the member search by a custom field

Former Member
Former Member

Can the search results on the member search page be sorted by an ExtendedAttributes or ProfileFields field?

Parents
No Data
Reply
  • Former Member
    0 Former Member in reply to Patrick M.

    Here's the code for the Plugin that I've written to handle the BeforeBulkIndex event for users. I've copied the DLL to the website's bin folder, and the JobServer folder. Does it look okay? How would I get the event to fire for all the users so that it would update all the users?

    using Telligent.Evolution.Extensibility;
    using Telligent.Evolution.Extensibility.Api.Entities.Version1;
    using Telligent.Evolution.Extensibility.Api.Version1;
    
    namespace UserData
    {
        public class UserDataPlugin : Telligent.Evolution.Extensibility.Version1.IPlugin
        {
            public string Name
            {
                get { return "UserDataPlugin"; }
            }
    
            public string Description
            {
                get { return "User Data Plugin"; }
            }
    
    
            public void Initialize()
            {
                Apis.Get<ISearchIndexing>().Events.BeforeBulkIndex += new BeforeSearchBulkIndexingEventHandler(UpdateSortOrder_BeforeBulkIndex);
            }
    
            private void UpdateSortOrder_BeforeBulkIndex(BeforeBulkIndexingEventArgs e)
            {
                UsersGetOptions o = new UsersGetOptions();
                var i = Apis.Get<IUsers>();
                foreach (SearchIndexDocument d in e.Documents)
                {
                    o.ContentId = d.ContentId;
                    var u = i.Get(o);
                    if (u != null)
                    {
                        d.AddField("UserSortOrder", u.ExtendedAttributes["SortOrder"].Value);
                    }
                }
            }
        }
    }

    Here's where I change the sort order in search.vm. Is this correct?

    #set ($searchListOptions = "%{ Query = $searchQuery, Sort = 'UserSortOrder', PageIndex = $pageIndex, PageSize = $pageSize }")

Children