Jump to:

3393 Posts in 976 Topics by 852 members

Template Questions

SilverStripe Forums » Template Questions » How to display the member group name (title) on the front-end?

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1600 Views
  • neilcreagh
    Avatar
    Community Member
    88 Posts

    How to display the member group name (title) on the front-end? Link to this post

    Hi, I want to display the member Group title on my template after a member has signed in rather than the member name. eg. "Acme Ltd." instead of "John Smith".

    I tried to create a new public function getGroupName() , so that I can call it on my template like so $Member.GroupName - but I'm not having any luck with it.

    Can anyone advise the simplest method to call this?

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: How to display the member group name (title) on the front-end? Link to this post

    I tried to create a new public function getGroupName() , so that I can call it on my template like so $Member.GroupName

    Well that function would have to be on the Member class (or a decorated instance of a member). One thing you would have to consider is that members has multiple groups so you would be dealing with a set rather than 1 group instance.

    In the template you could try

    <% control Member.Groups %>
    $Title
    <% end_control %>

  • neilcreagh
    Avatar
    Community Member
    88 Posts

    Re: How to display the member group name (title) on the front-end? Link to this post

    A much better solution, thank you.

    1600 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.