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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

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


Go to End


2 Posts   969 Views

Avatar
Double-A-Ron

Community Member, 607 Posts

28 September 2009 at 4:10pm

Edited: 28/09/2009 4:15pm

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

Community Member, 607 Posts

28 September 2009 at 4:15pm

Note to self - Check page database table structure

$myAccount->CanViewType = "LoggedInUsers";

This did exactly what I wanted.

Aaron