RSS Feed Subscribe to RSS Feed

Adding User Photo to WordPress User Profile

I finally got around to packaging up the Add User Photo plugin. You can download it here. Unzip it and upload to your plugins directory, and then activate it. You also need to 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">

Reader's Comments

  1. Mike Smith | January 14th, 2008 at 1:33 am

    Does anyone know for Wordpress MU, how you can display the 10 most recent profile pictures on the main page of the site? not the bloggers site, but the main site (ie: yoursite.com, not blogger.yoursite.com). I want to have a “Newest Members” section on the main page, but can’t figure this out.

    Any help is appreciated.

    Thanks,
    Mike

    Reply to this comment
  2. Bradley | January 14th, 2008 at 10:26 am

    Mike: If you figure it out, I’d love to know, too. My first thought would be just a category called “Newest Members” with (regular WP) posts that you could customize with their photo, some info, etc. Of course, that’s probably not automated either … anyway, just a thought.

    Reply to this comment
  3. Nandan | January 27th, 2008 at 7:46 am

    I think if you have a space in the name of the file then that gives you an err. I just renamed my .jpg to a std 8.3 file name and it worked for me.

    I want to show a page where I can display the author photo and his ‘About yourself’ information. any help is greatly appreciated.

    Thanks.

    Reply to this comment
  4. lauren | May 7th, 2009 at 9:42 pm

    Hi. My problem is that I can’t properly edit my /wp-admin/profile.php file. It’s only 20 lines long. If you can tell me where the edit I’m supposed to make belongs, I’ll be ready to go on to the next issue. For reference, the file looks like this:

    ?php
    /**
    * User Profile Administration Panel.
    *
    * @package WordPress
    * @subpackage Administration
    */

    /**
    * This is a profile page.
    *
    * @since unknown
    * @var bool
    */
    define(‘IS_PROFILE_PAGE’, true);

    /** Load User Editing Page */
    require_once(‘user-edit.php’);
    ?>

    (and thanks for your time. I’m sure the plugin is wonderful.)

    Reply to this comment
  5. Andrew Ferguson | May 30th, 2009 at 10:31 pm

    I’ve updated GiladG’s original comment with the code he sent me. I’ve also posted this other bit. Thanks for putting up with the situation until I can get it resolved!

    From GiladG:

    Another issue that I ran into with the plugin and was going to post a solution code was that when updating the profile page one must upload a picture each time because if no picture was included the update script would die saying ‘Please only upload jpg files!’. What I did to fix it was wrap the image processing portion with an IF so if a file was not uploaded the processing portion would be disregarded. So this is what it looks like now (blue is my addition (Editors note: just line one of the code)):

            if (is_uploaded_file($_FILES['photoUpload']['tmp_name'])) {
    
                if(($_FILES['photoUpload']['type'] == "image/jpeg") || ($_FILES['photoUpload']['type'] == "image/jpg")){
    
                        move_uploaded_file($_FILES['photoUpload']['tmp_name'], ABSPATH."/wp-content/images/".$userdata->user_login.".jpg");
    
                }
    
                else
    
                        //die("error: ".$_FILES['photoUpload']['error']);
    
                        die("<p><strong>Error:</strong> Please only upload jpg files! Your content type is <code>".$_FILES['photoUpload']['type']."</code></p><p>Please <a href='javascript:history.go(-1)' rel="nofollow">go back</a> and try again.</p>");
    
            }
    

    Either way, you made my life a whole lot easier with this plugin. Never thought it would be so easy to implement the upload. Thank you for that!

    Reply to this comment
    • GiladG | May 31st, 2009 at 3:20 am

      Thanks Andrew.

      Quick note, since the colors I had in my email do not show here, only the first line (IF STATEMENT) and the last line (CURLY BRACKET) are my addition. The rest is a part of the original code.

      Reply to this comment
  6. site indexed in free | December 20th, 2009 at 9:27 pm

    Hey guys,

    Just looking to use this plugin. I had made the changes in my useredit.php file. But when i try to upload the photo it shows me the same error everytime.

    Can you please update me with the new code please.

    Reply to this comment
  7. site indexed in free | December 20th, 2009 at 9:39 pm

    Hi,

    I had th problem i described in my last comment. The WP version – 2.8.6
    Plugin version – downloaded from above.

    My blog URL – http://www.financeandinsurancetips.com/

    Problem (once again) – Getting “Upload problem again and again”. I mean it says that Please upload .jpg photo. And shows a go back link.

    Do you have any more updated on thisplugin?

    Reply to this comment
  8. Cal | January 10th, 2010 at 4:07 pm

    A couple of notes –

    I’m using 2.9.1

    I had to edit line 125 instead of 182 in user-edit.php

    Also, I kept getting a weird error – content type is is pjpeg. Whatever that is? So I went ahead and edited fergcorp_addUserPhoto.php and made pjpeg instead jpeg an allowable content type.

    Then i had to add an images folder (CHMOD 777) in wp-content and now it seems to be working.

    Hope this helps for a future update.

    Reply to this comment
  9. Cal | January 10th, 2010 at 4:09 pm

    Hmm, no it’s not working actually. I see the image in my profile but it isn’t updating my past or future profile images in the comments sections.

    Reply to this comment

Leave a Comment

Gravatar: Get your picture displayed next to your comment: http://gravatar.com

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Code: To include code, bracket it with [code language="php"] and [/code].
Example: [code language="php"] echo "Hello, World!"; [/code]

Plugin Help: If your requesting help about a plugin, please provide as much information as possible. At the very least, include your WordPress Version and the Plugin Version!