Allow user to change avatar on their profile page

Install the netsti-uploader to add the upload feature in frontend for OctoberCMS.

Add the component to the profile page

{% component 'imageUploader' %}

and configure the model. We will match the "avatar" field of the Rainlab User plugin

For the last operation, extend the Rainlab/User model in the "Code" tab of the page.

function onInit()
    $user = Auth::getUser();
        $component = $this->addComponent(
            ['modelClass'=>'RainLab\User\Models\User','modelKeyColumn'=>'avatar', 'deferredBinding' => false]

        $component->bindModel('avatar', $user);

Thanks to iocare


Posted in OctoberCMS on Sep 05, 2016