Hello,
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:
<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>
and
Code:
<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>
2. Edit the profile.php file in the same directory to add the following (in it respective position, i.e. after the ABOUT_ME field):
Code:
// 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');
}
and
Code:
// 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');
}
3. Edit the profile.xml file in the subfolder called Profiles (root\plugins\user\profile\profiles\) to add the new field (again after the ABOUT_ME field):
Code:
<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"
/>
4. Add the text placeholders for the new field(s) you've added for the available site languages, in my case, English-UK and Bulgarian by editing the en-GB.plg_user_profile.ini file located in root\administrator\language\en-GB\ and correspondingly the other language file. In my case I have added:
Code:
PLG_USER_PROFILE_FIELD_USERPHOTO_LABEL="Photo"
PLG_USER_PROFILE_FIELD_USERPHOTO_DESC="User profile photo"
5. You can control the new field - required/optional/disabled - from Admin > Extensions > Plug-in Manager > User Plugin.
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:
<img src="images/userimg/crazy_teacher.jpg" border="0" alt="" />
And the image will load

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
