Jump to:

5537 Posts in 1737 Topics by 1223 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Create a class extending Member, but new users of this class don't show up in Security

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

Page: 1
Go to End
Author Topic: 823 Views
  • cobianzo
    Avatar
    Community Member
    8 Posts

    Create a class extending Member, but new users of this class don't show up in Security Link to this post

    Hi everybody;

    I have started to develop a new class

    class Customer extends Member

    I have created my custom forms to login and registering in my Page.php.

    Now, when any "customer" registers, it appears as another Member on my backend /Security area.

    I would like that they don't come up in this section, and only do it in my "Customer" area, created by me on the Admin model.

    The only solution that I see i creating a new section /Security_extended, then handle the data shown as I want to, showing tabs for different groups "Administators" and "Customers" . And then remove from tab in CMS the current Security.
    But I don't think this is a good solution, and obviously I don't want to put my hands on the Saphire to modify the Security area.

    Any idea? at least some clues or suggestions?

    Thanks

  • rob.s
    Avatar
    Community Member
    78 Posts

    Re: Create a class extending Member, but new users of this class don't show up in Security Link to this post

    Hi cobianzo,

    i did it the following way:

    I created a new Security group called "MyMembers".
    in mysite/_config.php i set the ID of that group:

    define('MYMEMBER_SECURITY_GROUP_ID', 3);

    When a new member is saved i used this code:

    ....
    ....
          $my_member->write();

          // Add the member to group. (Check if it exists first)
          if($group = DataObject::get_one('Group', "ID = " . MYMEMBER_SECURITY_GROUP_ID)) {
    $my_member->Groups()->add($group);

    }
    ......

    Then all "Members" are shown in the Security Tab inside that group.

    Greets,
    Rob

  • cobianzo
    Avatar
    Community Member
    8 Posts

    Re: Create a class extending Member, but new users of this class don't show up in Security Link to this post

    Great Rob, i will do it that way.
    I have another question:

    do actually the members belonging to this group still appear on the Security Members Tab? (the one that appears by default when you click on the Security Tab).

    i guess they do,right? Because I would like to hide them from that tab .
    I think I could do it by

    1) to include the new members (the customers in this case) as you say, in a different group as they are created (a group called customers).
    2) using the Decorator, to overwrites the function that shows the members in the Security tab and hide those members that belong to that group.
    (i dont know anything about decorators, actually, but i think they are used in these situations).
    What do you think about this solution?
    On the other hand, if anyone can apport any clue to how to hide the members that belong to a single group in the Security area with a Decorator, it's welcome

    Thanks!

  • rob.s
    Avatar
    Community Member
    78 Posts

    Re: Create a class extending Member, but new users of this class don't show up in Security Link to this post

    Hi,

    i'm a little confused ...

    Why do you want to hide your "Customers" inside the Security section ?

    Rob

  • cobianzo
    Avatar
    Community Member
    8 Posts

    Re: Create a class extending Member, but new users of this class don't show up in Security Link to this post

    Because I have created another Admin Tab called Customers that shows just the Customers members. That is easy. Now I want to separate the Security section from the Customer section, (as the Security section has to do with SS administrators and SS users, and the Customers has to do with the users of the front end website).
    I hope I explained it well. The point is how to hide the members of a group (or better, how not to show them) in the Security section.

    Is it a Decorator what I am looking for?

    Thanks in advance!

  • rob.s
    Avatar
    Community Member
    78 Posts

    Re: Create a class extending Member, but new users of this class don't show up in Security Link to this post

    hmm,

    what if you create a Tab for a new Model Admin and assign the Class "Customer" as single managed model ?

    Then you have a Tab where "Customers" can be handled and you can keep the Tab Security for admins only

    823 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.