Uploading on the Front End
-
For anybody interested in having their users be able to upload an avatar on the front end, I was able to complete a work-around on my site. I created a form whereby they can upload an image, which gets saved as a custom field (as user meta). After the upload is complete, I used a hook to fire a custom function that takes that user meta and assigns it to the avatar.
Here is the pertinent section of the code, which you would work into your own site depending on how you process forms and file uploads:
// get the current user id $user_id = get_current_user_id(); // get the ID of the image just uploaded $avatar_url = get_user_meta($user_id, 'REPLACE-WITH-YOUR-CUSTOM-FIELD', true); // update the user's avatar $sla = new Simple_Local_Avatars(); $sla->assign_new_user_avatar( $avatar_url, $user_id );
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Uploading on the Front End’ is closed to new replies.