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
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
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 />");
}
}
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.
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.
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.
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.
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
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.
Tarik, This is all for Umbraco 7... But i am on Umbraco 8
anyhow, i have a working solution.
this is resulting in a list with all typedcontent items in a list that contains all kind of Members
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:
This was tested against v8.0.2
I know what I mentioned, you informed v8 and also the post tagged for v8.
I got that result for v8 too see here.
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.
For the how to I mentioned an answer and the service documentation too.
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.
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.
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.
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.
is working on a reply...