src/Pages/MemberProfilePageController.php
protected function indexProfile()
    {
        if (!$this->AllowProfileEditing) {
            if ($this->AllowAdding && Injector::inst()->get(Member::class)->canCreate()) {
                return $this->redirect($this->Link('add'));
            }

            return Security::permissionFailure($this, _t(
                'MemberProfiles.CANNOTEDIT',
                'You cannot edit your profile via this page.'
            ));
        }

        $member = Member::currentUser();

        foreach ($this->Groups() as $group) {
            if (!$member->inGroup($group)) {
                return Security::permissionFailure($this);
            }
        }

        $form = $this->ProfileForm();
        $form->loadDataFrom($member);

        if ($password = $form->Fields()->fieldByName('Password')) {
            if ($password->hasMethod('setCanBeEmpty')) {
                $password->setCanBeEmpty(false);
                $password->setValue(null);
                $password->setCanBeEmpty(true);
            } else {
                // If Password field is ReadonlyField or similar
                $password->setValue(null);
            }
        }

        $data = array(
            'Type'    => 'Profile',
            'Title'   => $this->obj('ProfileTitle'),
            'Content' => $this->obj('ProfileContent'),
            'Form'    => $form
        );

        return $this->customise($data);
    }
protected function indexProfile()
    {
        if (!$this->AllowProfileEditing) {
            if ($this->AllowAdding && Injector::inst()->get(Member::class)->canCreate()) {
                return $this->redirect($this->Link('add'));
            }

            return Security::permissionFailure($this, _t(
                'MemberProfiles.CANNOTEDIT',
                'You cannot edit your profile via this page.'
            ));
        }

        $member = Member::currentUser();

        foreach ($this->Groups() as $group) {
            if (!$member->inGroup($group)) {
                return Security::permissionFailure($this);
            }
        }

        $form = $this->ProfileForm();
        $form->loadDataFrom($member);

        if ($password = $form->Fields()->fieldByName('Password')) {
            if ($password->hasMethod('setCanBeEmpty')) {
                $password->setCanBeEmpty(false);
                $password->setValue(null);
                $password->setCanBeEmpty(true);
            } else {
                // If Password field is ReadonlyField or similar
                $password->setValue(null);
            }
        }

        $data = array(
            'Type'    => 'Profile',
            'Title'   => $this->obj('ProfileTitle'),
            'Content' => $this->obj('ProfileContent'),
            'Form'    => $form
        );

        return $this->customise($data);
    }
protected function indexProfile ( ) { if ( ! $ this -> AllowProfileEditing ) { if ( $ this -> AllowAdding && Injector :: inst ( ) -> get ( Member :: class ) -> canCreate ( ) ) { return $ this -> redirect ( $ this -> Link ( 'add' ) ) ; } return Security :: permissionFailure ( $ this , _t ( 'MemberProfiles.CANNOTEDIT' , 'You cannot edit your profile via this page.' ) ) ; } $ member = Member :: currentUser ( ) ; foreach ( $ this -> Groups ( ) as $ group ) { if ( ! $ member -> inGroup ( $ group ) ) { return Security :: permissionFailure ( $ this ) ; } } $ form = $ this -> ProfileForm ( ) ; $ form -> loadDataFrom ( $ member ) ; if ( $ password = $ form -> Fields ( ) -> fieldByName ( 'Password' ) ) { if ( $ password -> hasMethod ( 'setCanBeEmpty' ) ) { $ password -> setCanBeEmpty ( false ) ; $ password -> setValue ( null ) ; $ password -> setCanBeEmpty ( true ) ; } else { // If Password field is ReadonlyField or similar $ password -> setValue ( null ) ; } } $ data = array ( 'Type' => 'Profile' , 'Title' => $ this -> obj ( 'ProfileTitle' ) , 'Content' => $ this -> obj ( 'ProfileContent' ) , 'Form' => $ form ) ; return $ this -> customise ( $ data ) ; }
Allows users to edit their profile if they are in at least one of the
groups this page is restricted to, and editing isn't disabled.

If editing is disabled, but the current user can add users, then they
are redirected to the add user page.

@return array|ViewableData_Customised
Allows users to edit their profile if they are in at least one of the groups this page is restricted to and editing isn t disabled .