I have been playing with the User Plugin in 1.6 (since Beta 13). I have managed to add my own fileds for additional user information but now I'd also like to add the option for the user to add their own photo.
So far, I've simply repeated the steps for adding a new text/list/textarea field. Here they are in case someone needs them:
1. In profile.xml (root\plugins\user\profile\) add a new field for both the registration stage and the profile edit stage (in their respective positions, i.e. after the ABOUT_ME field):
Code: Select all
<field
name="register-require_userphoto"
type="list"
default="0"
label="PLG_USER_PROFILE_FIELD_USERPHOTO_LABEL"
description="PLG_USER_PROFILE_FIELD_USERPHOTO_DESC"
>
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
<option value="0">JDISABLED</option>
</field>
Code: Select all
<field
name="profile-require_userphoto"
type="list"
default="0"
label="PLG_USER_PROFILE_FIELD_USERPHOTO_LABEL"
description="PLG_USER_PROFILE_FIELD_USERPHOTO_DESC">
<option value="2">JOPTION_REQUIRED</option>
<option value="1">JOPTION_OPTIONAL</option>
<option value="0">JDISABLED</option>
</field>
Code: Select all
// Toggle whether the userphoto field is required.
if ($this->params->get('profile-require_userphoto', 1) > 0) {
$form->setFieldAttribute('userphoto', 'required', $this->params->get('profile-require_userphoto') == 2, 'profile');
} else {
$form->removeField('userphoto', 'profile');
}
Code: Select all
// Toggle whether the userphoto field is required. EDITED BY CHEESEUS
if ($this->params->get('register-require_userphoto', 1) > 0) {
$form->setFieldAttribute('userphoto', 'required', $this->params->get('register-require_userphoto') == 2, 'profile');
} else {
$form->removeField('userphoto', 'profile');
}
Code: Select all
<field
name="userphoto"
type="text"
description="PLG_USER_PROFILE_FIELD_USERPHOTO_DESC"
label="PLG_USER_PROFILE_FIELD_USERPHOTO_LABEL"
message="PLG_USER_PROFILE_FIELD_USERPHOTO_MESSAGE"
size="30"
/>
Code: Select all
PLG_USER_PROFILE_FIELD_USERPHOTO_LABEL="Photo"
PLG_USER_PROFILE_FIELD_USERPHOTO_DESC="User profile photo"
Now, all of the above works for all types of fields other than IMAGES.
I need help creating a new image field with the option to browse the user's computer for images, and then for displaying the selected image as an image, not as text.
My idea to implement this is very simple and certainly leaving much to be desired but it works:
--- From the front-end (or back-end) go to Edit Profile and in the new text field called USERPHOTO type the HTML tag for image:
Code: Select all
<img src="images/userimg/crazy_teacher.jpg" border="0" alt="" />
This, however, does not make it easy on the ordinary user. It is actually impossible for them to add their own photo.
What is lacking is:
1. A file upload functionality that will put the user image in the relevant root/images/userimg folder.
2. A script checking the type and size of the user image.
I could really use some professional Joomla-coding help here