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">
This entry was posted in Programming. Bookmark the permalink.

58 Responses to Adding User Photo to WordPress User Profile

  1. Mike Smith says:

    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

  2. Bradley says:

    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.

  3. Nandan says:

    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.

  4. lauren says:

    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.)

  5. 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!

    • GiladG says:

      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.

  6. site indexed in free says:

    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.

  7. site indexed in free says:

    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?

  8. Cal says:

    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.

  9. Cal says:

    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.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <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!