Overview
Allows adding a photo to a user profile
Compatibility
- 2.1.*
- 2.0.*
- 1.5 (in theory, not tested)
Installation
Download the file and put it in your plugins directory. In your wp-content folder, create a directory called images and make sure that it was write permissions.
Modify line 21 of /wp-admin/profile.php, adding enctype="multipart/form-data" to the form tag. So at the end of the day, line 21 should look like:
<form name="profile" id="your-profile" action="profile-update.php" method="post" enctype="multipart/form-data">
Activate plugin.
Usage
User will now be able to upload a jpg-based image. The image is uploaded and renamed to their username with a jpg extension (e.g. johndoe.jpg).
The file is located in /wp-content/images/
To use the file, simply reference its location. This can be done using an absolute reference (i.e. pointing to an image at http://www.example.com/wp-content/images/johndoe.jpg) or through PHP programming.
Example:
If you know the UserID, but not the username, you can do a simple lookup:
$userLogin= $wpdb->get_var("SELECT $wpdb->users.user_login FROM $wpdb->users WHERE $wpdb->_users.ID = ".$someUserID.");
if(file_exists(ABSPATH."wp-content/images/".$userLogin.".jpg"))
$imageURL = get_bloginfo('url')."/wp-content/images/".$userLogin.".jpg";
else
$imageURL = get_bloginfo('url')."/wp-content/images/unknown.jpg";;
echo "<img src=\"$imageURL\" />";
In the above example, an addition file, unknown.jpg, has been placed in the images directory to serve as a placeholder for users who haven’t uploaded images. You also need to specify the value of $someUserID.
Download
Latest Version:
Hello Andrew,
I was wondering how can I add the photo to the author.php page, I was using user photo, which had a couple of commands that I could add to call the photo.
* userphoto_the_author_photo()
* userphoto_the_author_thumbnail()
* userphoto_comment_author_photo()
* userphoto_comment_author_thumbnail()
Do you have similar commands for your plugin?
Also, I have over 200 people in my company. I was wondering if I have your plugin installed, and I place all 200 photos in the images folder will it let them be associated to that person. or will I need to go into each persons profile and upload the photo for them.
Thanks,
Aaron
@Aaron:
I haven’t done much with this code recently. The code really just serves to provide a couple of hooks to make it easier to upload the data and leaves it up to you to develop the code to bring back out.
Take a look at previous comments; if you still need help developing the code, I am available for hire at very reasonable rates.
Hello Andrew,
I have tried implementing as you suggested; however, I do not have a line 21. and when I try changing line 61 to
if(1){and then I try uploading a photo it goes through the motions, but no image is uploaded.Before, it gave me the same error that Aike had, Error: Please only upload jpg files! Your content type is.
Do you know how I can get it to upload?
Thanks,
Aaron
@Aaron:
As listed above, please note the compatibility of this plugin is only for:
If you need help updating the code for a current version of WordPress, I am available for hire at very reasonable rates.
Hi Andrew,
Could you update your plugin and add a simple JQuery to replace the form encrypt
$('form#your-profile').attr((this.encoding ? 'encoding' : 'enctype') , 'multipart/form-data');
and that way users wont have to edit core files.
Bainternet.
@bainternet:
I haven’t worked on this code for sometime. I should probably update this page to mention that I’ve unfortunately had to abandon this code. Part of the reason is that this code came from project that I now longer work on, the other part is that I just don’t have enough time to maintain this code for free.
If you need help updating the code for a current version of WordPress (which could include implementing jQuery), I am available for hire at very reasonable rates.
I would also encourage you to fork the code and create your own version.
[...] Add User Photo to WordPress User Profile [...]
[...] Menambahkan Foto Pengguna ke Profil Pengguna WordPress [...]
Can i get plugins for this?