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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

[SOLVED] Set Access to "Logged-in users" in code


Reply

2 Posts   626 Views

Avatar
Double-A-Ron

28 September 2009 at 4:10pm (Last edited: 28 September 2009 4:15pm), Community Member, 604 Posts

Hiya,

I'm creating a registration module. The "MyAccount" page obvoiusly needs to be set to be viewable by "Logged-in users" by default when installed.

Is there a way to do this in my requireDefaultRecords method? I'm building the default page like so:

$myAccount = new MyAccountPage();
$myAccount->Title = "My Account";
$myAccount->URLSegment = "my-account";
$myAccount->Status = "Published";
$myAccount->write();
$myAccount->publish("Stage", "Live");

Any ideas?

Aaron

Avatar
Double-A-Ron

28 September 2009 at 4:15pm Community Member, 604 Posts

Note to self - Check page database table structure

$myAccount->CanViewType = "LoggedInUsers";

This did exactly what I wanted.

Aaron