I have been following goldenapples front end file uploads tutorial, however i do have that working for my frontend posting page, but what i am wanting to accomplish now is to add an image from edit profile page (again this is a frontend file upload scenario.
In theme functions.php i have:
function insert_complogo($file_handler,$user_id,$setthumb='false') {
// check to make sure its a successful upload
if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false();
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
$attach_id = media_handle_upload( $file_handler, $user_id );
if ($setthumb) update_usermeta($user_id,'_thumbnail_id',$attach_id);
return $attach_id;
}
In my profile-edit.php at the top i have:
if ($_FILES) {
foreach ($_FILES as $file => $array) {
$newupload = insert_complogo($file,$user_id);
}
}
also this:
if ( !empty( $_POST['authorphoto'] ) )
update_usermeta( $current_user->id, 'comp_logo', esc_attr($_POST['comp_logo'] ) );
and my input type is:
<p>
<label><?php _e('Add Company Logo', 'comp_logo') ?></label><br />
<input type="file" name="comp_logo" id="comp_logo" value="Upload Logo" size="50" />
</p>
As you can tell from the first three blocks of code above i have changed post_id references to user_id,
Now the upload of the company logo does work, however even using user_id and update_usermeta the info is being saved into wp_postmeta table which is not where i want it to be as i need to pull the info from wp_usermeta to populate the author.php page.
So my question (got there eventualy) is why when im using update_usermeta is the attachment info going into wp_postmeta, im guessing its because codex says that image attachments are a type of post so no matter what that is where they go, but how can i get that image from wp_postmeta and associate it with the correct author?