Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save champsupertramp/6b73195db24eb6650a23b4440b4287c3 to your computer and use it in GitHub Desktop.
Save champsupertramp/6b73195db24eb6650a23b4440b4287c3 to your computer and use it in GitHub Desktop.
Ultimate Member - Allow everyone to upload profile and cover photos on front-end pages.
/**
* Ultimate Member - Customization
* Description: Allow everyone to upload profile and cover photos on front-end pages.
*/
add_filter("um_user_pre_updating_files_array","um_custom_user_pre_updating_files_array", 10, 1);
function um_custom_user_pre_updating_files_array( $arr_files ){
if( is_array( $arr_files ) ){
foreach( $arr_files as $key => $details ){
if( $key == "userphoto" ){
unset( $arr_files[ $key ] );
$arr_files[ "profile_photo" ] = $details;
}
}
}
return $arr_files;
}
add_filter("um_allow_frontend_image_uploads","um_custom_allow_frontend_image_uploads",10, 3);
function um_custom_allow_frontend_image_uploads( $allowed, $user_id, $key ){
if( $key == "profile_photo" ){
return true;
}
return $allowed; // false
}
@champsupertramp
Copy link
Author

Hello @everyone - Here's the latest version of custom Upload Profile Photo for Ultimate Member 2.0:

https://gist.github.com/champsupertramp/a7ce812c702865cb973445c9fe7a9544

By the way, i will be accepting custom code requests on my website www.champ.ninja

Thank you,

@alybyerly
Copy link

Hey thanks for this code! I am having trouble getting the image to show as the profile image on the general account page. Also, is there a way to add an option on the general account page once you are logged in to change/update the profile image? Thanks!!

@champsupertramp
Copy link
Author

Hi Everyone,

I'll be sharing some Ultimate Member customizations & tutorials on my website: www.champ.ninja

Subscribe to my newsletter to get the latest tutorials.

Regards,

@askmemobile
Copy link

Can any one send me the code to add cover photo

@nishani7234
Copy link

Hi,

  1. Copy the above code in your theme's function.php file. Should be in public_html/wp-content/themes/your-themes-name/function.php
  2. In ultimate member add 'upload image' field in registration form.
  3. Enter meta key as 'userphoto' (i.e same as in the code above)
  4. Profit.

Hi,
This is working fine.
But when updating the ultimate member plugin, user profile picture removed. Please help me.

@AzmayenFayek
Copy link

During upload it’s showing "the image is too large" but actually not a large image at all. I tried many sizes,resulations,formates.
Please help me to fix it.
Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment