Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS /

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


Reply


6 Posts   882 Views

Avatar
cobianzo

Community Member, 8 Posts

4 September 2010 at 8:01pm

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

Avatar
rob.s

Community Member, 78 Posts

5 September 2010 at 8:37pm

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

Avatar
cobianzo

Community Member, 8 Posts

5 September 2010 at 11:21pm

Edited: 05/09/2010 11:51pm

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!

Avatar
rob.s

Community Member, 78 Posts

6 September 2010 at 12:16am

Hi,

i'm a little confused ...

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

Rob

Avatar
cobianzo

Community Member, 8 Posts

6 September 2010 at 5:03am

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!

Avatar
rob.s

Community Member, 78 Posts

6 September 2010 at 5:41am

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