Add User Photo

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:

80 Responses to Add User Photo

  1. lauren says:

    I posted a detailed request for help, and it appears to have disappeared. Before I retype the whole thing, I will look and see what happens to this.

  2. lauren says:

    Ok, let me try this again.

    I can’t edit line 21 of /wp-admin/profile.php because the file is only 20 lines long.

    The complete file is below. Please tell me how I modify it to get this plugin to work.

  3. Paul Boyce says:

    Does this have the ability to upload more than one picture per profile? I am dying for a solution to make this happen.

  4. Tina says:

    Andrew,
    I just installed this – and it appears to be be working although I did not edit the profile.php (when I did it caused syntax errors).

    Is there a way to get the photos to show up in a sidebar?

    Thanks for this plugin!

    Tina

  5. Shutter says:

    huge thanks for plugin!

  6. Toni L says:

    It’s a great idea, I’ve just never really understood why this isn’t part of the core as an option.
    Concerning your plugin, have you investigated is there a possibility to add option to an user profile without modifying the core? Send the plugin to the developement team, you never know, it might get accepted.

    • @Toni L

      I haven’t done any work on this plugin since WordPress 2.1 was released. At the time, there was no way to interface without hacking (i.e. mod-ing) the core. However, I would imagine that there are some new hooks that could be used. Unfortunately, I don’t have the time to continue to develop this on my own time, unless someone where to sponsor development.

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!