Jump to:

22972 Posts in 11596 Topics by 2824 members

General Questions

SilverStripe Forums » General Questions » [SOLVED] Set Access to "Logged-in users" in code

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

Page: 1
Go to End
Author Topic: 581 Views
  • Double-A-Ron
    Avatar
    Community Member
    599 Posts

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

    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

  • Double-A-Ron
    Avatar
    Community Member
    599 Posts

    Re: [SOLVED] Set Access to "Logged-in users" in code Link to this post

    Note to self - Check page database table structure

    $myAccount->CanViewType = "LoggedInUsers";

    This did exactly what I wanted.

    Aaron

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