Jump to:

1036 Posts in 810 Topics by 315 members

Forum Module

SilverStripe Forums » Forum Module » Changing logout page on Forum

Discuss the Forum Module.

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

Page: 1
Go to End
Author Topic: 2381 Views
  • mschiefmaker
    Avatar
    Community Member
    187 Posts

    Changing logout page on Forum Link to this post

    I want the browser to go to a non-standard login page after a user has logged out but I am not sure how to get this to work. The logout function

    function logout() {
          if($member = Member::currentUser())
             $member->logOut();
          $returnTo = DataObject::get_one("ForumHolder");
          if($returnTo)
             return Director::redirect(Director::absoluteBaseURL().$returnTo->URLSegment);
          else {
             return Director::redirectBack();
          }
       }

    Uses a $returnTo Variable, where do I change this?

    Thanks

    MM

  • Nivanka
    Avatar
    Community Member
    395 Posts

    Re: Changing logout page on Forum Link to this post

    You can do this easily, Extend your Page class and create a new page type; So lets say this page type is LoggedOutPage.

    Now what you have to do is that to rewrite the logout function.

    function logout() {
    if($member = Member::currentUser())
    $member->logOut();
    $returnTo = DataObject::get_one("LoggedOutPage");
    if($returnTo)
    return Director::redirect(Director::absoluteBaseURL().$returnTo->URLSegment);
    else {
    return Director::redirectBack();
    }
    }

    this way you can redirect the users to any page. but make sure you prevent editing the core codes. otherwise when updating the modules, cms or the framework you will miss the cstomizations you did.

  • mschiefmaker
    Avatar
    Community Member
    187 Posts

    Re: Changing logout page on Forum Link to this post

    Feeling kind of stupid. I just did not see that line. Thanks
    MM

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