Copied to clipboard

Flag this post as spam?

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


  • Lander Debeuf 23 posts 125 karma points
    Jun 12, 2019 @ 20:39
    Lander Debeuf
    0

    Member List

    I want to make a SelectList with all the members of a certain type in umbraco V8. This was easy with the memberservice in the past, but how does it work now with Umbraco v8? I can't seem to find this

    br, L

  • Tarik 196 posts 840 karma points c-trib
    Jun 12, 2019 @ 22:23
    Tarik
    0

    Lander Debeuf, that seems similar to what I mentioned as a result in this post.

    I suggest that you iterate through the roles and for each one query members of it and append all to a list of members.

  • Lander Debeuf 23 posts 125 karma points
    Jun 12, 2019 @ 22:51
    Lander Debeuf
    0

    Tarik, This is all for Umbraco 7... But i am on Umbraco 8

    anyhow, i have a working solution.

            var AllUsers = Membership.GetAllUsers();
            List<IPublishedContent> members = new List<IPublishedContent>();
    
            foreach(MembershipUser user in AllUsers)
            {
                var newMember = helper.Member(user.ProviderUserKey);
                members.Add(newMember);
            }
    

    this is resulting in a list with all typedcontent items in a list that contains all kind of Members

  • Brandon Osborne 38 posts 161 karma points c-trib
    Jun 12, 2019 @ 23:21
    Brandon Osborne
    100

    Heya Lander,

    That is close, but isn't exactly what you want. :) You said that you want members of a certain type and that is still achievable in v8 with the MemberService, but the code is slightly different. This is what you actually want:

    @using Umbraco.Core.Services
    @using ContentModels = Umbraco.Web.PublishedModels;
    
    @{
        IMemberService memberService = Services.MemberService;
    
        var standardMembers = memberService.GetMembersByGroup(@"Standard");
    
        foreach (var member in standardMembers)
        {
            Response.Write($"{member.Name} <br />");
        }
    }
    

    This was tested against v8.0.2

  • Tarik 196 posts 840 karma points c-trib
    Jun 13, 2019 @ 00:02
    Tarik
    0

    I know what I mentioned, you informed v8 and also the post tagged for v8.

    I got that result for v8 too see here.

  • Brandon Osborne 38 posts 161 karma points c-trib
    Jun 13, 2019 @ 00:45
    Brandon Osborne
    0

    He never said a single word about wanting it to work in the back office. He said he wanted to populate a SelectList, which infers that he would like to use this in a view, which is why he mentioned the member service & I gave him the code to accomplish that a couple of hours ago.

  • Tarik 196 posts 840 karma points c-trib
    Jun 13, 2019 @ 06:34
    Tarik
    0

    For the how to I mentioned an answer and the service documentation too.

    I suggest that you iterate through the roles and for each one query members of it and append all to a list of members.

  • Brandon Osborne 38 posts 161 karma points c-trib
    Jun 13, 2019 @ 06:55
    Brandon Osborne
    0

    Yes Tarik, you did mention the Member Service, as did Lander. The problem is the documentation you posted is outdated and doesn't work with v8 and clearly says that at the top of the page. Both myself & Lander have already told you the same thing. At any rate, the answer has been selected.

    Have a great day. Ciao.

  • Lander Debeuf 23 posts 125 karma points
    Jun 13, 2019 @ 06:50
    Lander Debeuf
    1

    Thx Brandon for the solution, this is indeed a solution i can use for a selectlist.

    However would you also have a solution to achieve the same thing in the backend? Because i tend to do everything in the backend, and only use a viewModel to render the data in the frontEnd.

    But nevertheless, it is a solution i can use for now.

    Tarik,

    Thx for the effort, but that is not quite what i am looking for. this is more about a plugin to have in the umbraco backend to work with members. I just would like the have the members in my surfaceController.

  • Brandon Osborne 38 posts 161 karma points c-trib
    Jun 13, 2019 @ 07:03
    Brandon Osborne
    1

    My pleasure, Lander. I did something like this in v6 and v7 in the backoffice, but it seems to be royally exploding when I try similar in v8. I have to work on a couple of things, but I'll come back around to it. It sounds like Tarik actually has this figured out if he can stop pitching his little extension long enough to help.

  • Brandon Osborne 38 posts 161 karma points c-trib
    Jun 14, 2019 @ 13:08
    Brandon Osborne
    0

    Sorry for the delay, Lander,

    Wouldn't a quick solution be to convert my code into a macro? Then you can put it in any RTE.

Please Sign in or register to post replies

Write your reply to:

Draft