1

We have user profile page in frontend. We need to add functionality to user add their profile image from profile page in frontend.

Is any plugin or custom functions available for that ?

1

You could use the WP User Avatar plugin for this.

| improve this answer | |
1

As far as I am aware of the native WordPress user avatar is not able to be modified by the theme, or website, but only by the user itself (it would be hard to change a user's Gravatar for example).

You could update the user meta with a custom profile picture by utilizing the personal_options_update and edit_user_profile_update hooks, and use wp.media from the Javascript API to call the WordPress media uploader and let the user upload their picture.

add_action( 'personal_options_update', 'save_user_profile_picture' );
add_action( 'edit_user_profile_update', 'save_user_profile_picture' );

function save_user_profile_picture( $user_id ) {

if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }

    update_user_meta( $user_id, 'address', $_POST['profile_picture'] );

}

There's a nice writeup on wp.media here.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.