Making a field recognized in registration form

Kirk

Well-known member
So i'm trying to add the ability to allow users to upload an avatar on registration but the input name i have right now is saying Avatar is not a valid field. I'm assuming i need to extend the Register underneath the public controller to make it a valid field? Could anyone correct me on this?
 
I did a template modification for the registration_form

Find:
Code:
<xen:if is="mt_rand(0, 2) == 1">
    <dl class="ctrlUnit limited">
        <dt><label for="ctrl_{$fieldMap.email_hp}">{xen:phrase email}:</label></dt>
        <dd>
            <input type="email" name="{$fieldMap.email_hp}" value="" dir="ltr" class="textCtrl" autocomplete="off" id="ctrl_{$fieldMap.email_hp}" />
            <p class="explain">{xen:phrase please_leave_this_field_blank}</p>
        </dd>
    </dl>
    </xen:if>
Replace
Code:
$0
    <dl class="ctrlUnit">
        <dt><label>{xen:phrase upload_avatar}:</label></dt>
        <dd><input type="file" class="OptIn" name="avatar"/></dd>
    </dl>
 
Try it:
Code:
<dl class="ctrlUnit OptIn">
        <dt><label>{xen:phrase upload_avatar}:</label></dt>
        <dd><input type="file" name="avatar"/></dd>
    </dl>

If not work. You can use the name avatar_date instead of avatar
 
Try it:
Code:
<dl class="ctrlUnit OptIn">
        <dt><label>{xen:phrase upload_avatar}:</label></dt>
        <dd><input type="file" name="avatar"/></dd>
    </dl>

If not work. You can use the name avatar_date instead of avatar
Tried that it doesn't throw an error. However after registration it shows the default avatar.
 
I have a feeling i`m doing something for my ControllerPublic/Register

PHP:
<?php
class KK_avatarOnRegistration_ControllerPublic_register extends XFCP_KK_avatarOnRegistration_ControllerPublic_register
{
    public function applyAvatar()
    {
        $userid = $this->_
        //Grab image from user
        $avatar = $this->_input->filterSingle('avatar_date', XenForo_Input::UINT);

        //create instance of XenForo's User's DataWriter
        $dw = XenForo_DataWriter::create('XenForo_DataWriter_User');

        //Set the field with the data we filtered
        $dw->set('avatar_date', $avatar);

        //Lets save into the database
        $dw->save();

        //Lets send a response to the user, so he knows everything is A OK
        return $this->responseRedirect(
            XenForo_ControllerResponse_Redirect::SUCCESS,
            $this->getDynamicRedirect()
        );
    }
    /**
     * Grab XenForo Avatar Model
     * @return getMdelFromCache
     */
    protected function _getAvatarModel()
    {
        return $this->getModelFromCache ('XenForo_Model_Avatar');
    }
}
 
Top Bottom