If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!
So the story goes like this as usual.
John, I need to have some way of uploading the author’s image. I don’t know what the heck the previous idiots were doing. They uploaded it themselves. I don’t want to call you every time I need to upload an author’s image.
So the previous solution that some guys gave him required to upload images using the ftp, and it looked like that he was afraid to death to use ftp. I could understand. An average Joe would be. So what he needed was a simple solution that would allow him to upload the photos of the author on his multi author blogging site.
Fortunately, a straightforward solution already exist from semiologic at Author’s Image Plugin. At my first glance I thought I am done right after installing the plugin. I only needed to modify the theme so that it actually use the_author_image() to get the actual image. But I was wrong. Here is why.
The Author’s Image Plugin inserts the image upload form in the current user’s own profile, so only individual authors could upload their own image. This was not what was required in my case. My client wanted to upload the image himself as admin. As I searched the forums on semilogic.com. I found a post from the author that it is not possible as WordPress does not have a hook in the right place. I believe when this was written, it could be true. But not anymore, and the author of the plugin just has not got time to make the change.
The solution is not so difficult. What I needed to do was to modify the plugin to hook at the right point, and then pick up the correct author id, and here is how I did that :
The admin module is in a file called sem-author-image-admin.php. As with any other plugin, it uses hooks to display and save the image in the init function. I modified to place the hook at different point as follows.
// comment the following two lines
// add_action('show_user_profile', array('author_image_admin', 'display_image'));
// add_action('personal_options_update', array('author_image_admin', 'save_image'));
// add the following two lines
add_action('edit_user_profile', array('author_image_admin', 'display_image'));
add_action('profile_update', array('author_image_admin', 'save_image'));
Secondly save_image() picks the login of the current logged in user and uses its name to save the file. Since I need to save the file by admin, the admin will always be the current user. So I need to change the save_image() function to accept the user_id [which is conviniently passed by the hook] as .
function save_image($user_id)
{
if ( @ $_FILES['author_image']['name'] )
{
// comment the following two lines
// $user_ID = $_POST['checkuser_id'];
// $user = get_userdata($user_ID);
// add the following one lines
$user = get_userdata($user_id);
$author_id = $user->user_login;
....
....
You have to do the same in the block, for deleting the image. What is left now after that is to modify the theme. I guess you can do that without my help ![]()
Browse more posts marked in:
;


There are no comments yet...Be the first by filling out the form below.
Leave a Comment