RSS Feed Subscribe to RSS Feed

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:

Reader's Comments

  1. lauren | May 7th, 2009 at 10:40 pm

    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.

    Reply to this comment
  2. lauren | May 7th, 2009 at 10:51 pm

    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.

    Reply to this comment
  3. Paul Boyce | June 5th, 2009 at 11:20 pm

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

    Reply to this comment
  4. Tina | September 14th, 2009 at 10:13 pm

    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

    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!