Title: Upload photo using Gravity Forms User Registration
Last modified: August 30, 2016

---

# Upload photo using Gravity Forms User Registration

 *  [tystra](https://wordpress.org/support/users/tystra/)
 * (@tystra)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/upload-photo-using-gravity-forms-user-registration/)
 * Hi there, my theme uses your plugin for the users photo and I am registering 
   users using Gravity Forms User Registration add-on. When I connect the file upload
   in gravity forms to the custom field “cupp_upload_meta” it uploads with no problem
   in the back-end of the user profile. However, on the front-end, the image doesn’t
   take effect and does not display at all.
 * Do you know why this may be happening, or is there another custom field that 
   is involved that I am missing? Or has anyone else tried with Gravity Forms User
   Registration and been successful?
 * Any help of direction appreciated, thank you.
 * [https://wordpress.org/plugins/custom-user-profile-photo/](https://wordpress.org/plugins/custom-user-profile-photo/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [prodesignra](https://wordpress.org/support/users/prodesignra/)
 * (@prodesignra)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/upload-photo-using-gravity-forms-user-registration/#post-6542626)
 * This would be useful for me as well! Thanks!
 *  Thread Starter [tystra](https://wordpress.org/support/users/tystra/)
 * (@tystra)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/upload-photo-using-gravity-forms-user-registration/#post-6542634)
 * My theme uses this code to display using CUPP:
 *     ```
       <?php
       // Retrieve The Post's Author ID
       $user_ID = get_the_author_meta('ID');
       // Set the image size. Accepts all registered images sizes and array(int, int)
       $size = 'author-avatar';
       // Get the image URL using the author ID and image size params
       if (get_cupp_meta( $user_ID, $size )):
       $imgURL = get_cupp_meta($user_ID, $size);
       else :
       $imgURL = WP_THEME_URL . '/imgcust/default-author-image.jpg';
       endif;
       ?>
       <!-- Print the image on the page -->
       <img class="theme_image" src="<?php echo esc_url ( $imgURL );?>"/>
       ```
   
 * After uploading with Gravity Forms it displays great in the back-end of WordPress
   in the users page, however it will not pull the photo and display it on the front-
   end. Even if I click “Update User” in the back-end, the front-end still does 
   not display it. Any help from admin or anyone is much appreciated!
 *  [3five](https://wordpress.org/support/users/3five/)
 * (@3five)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/upload-photo-using-gravity-forms-user-registration/#post-6542636)
 * Thank you for the update on this issue. We are working to see if we can resolve
   this with the use of gravity forms and the User Registration add on.
 * We will let you know as soon as we can if this is possible and if we can support
   it.
 * Thanks,
    3five
 *  [Markus](https://wordpress.org/support/users/markusgt/)
 * (@markusgt)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/upload-photo-using-gravity-forms-user-registration/#post-6542655)
 * I would love to have this too.
 *  [HarroH](https://wordpress.org/support/users/harroh/)
 * (@harroh)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/upload-photo-using-gravity-forms-user-registration/#post-6542672)
 * Hi Guys,
 * We had the same issue. Problem is that Gravity Forms uploads its images in a 
   separated folder, not wanting to contaminate the media library with uploads via
   forms. A noble idea but that creates a problem with this plugin as the get_cupp_meta()
   function only checks for images that are in the media library. So when using 
   Gravity Forms User Registration, Gravity Forms actually does update the correct
   meta values but the get_cupp_meta cannot find the image and will return your 
   gravatar image or blank.
 * So what you need to do it hook into the Gravity Forms after submit hook and run
   a sideload to put the image into the media library and update the cupp meta values.
   This way get_cupp_meta() can find the image and will return the correct URL.
 * Example code:
 *     ```
       add_action( 'gform_after_submission, 'gf_process_user_update', 10, 2 );
   
       function gf_process_user_update( $entry, $form ) {
   
       	foreach ( $form['fields'] as &$field ) :
   
       		if ( strpos( $field->cssClass, 'gform_user_photo' ) !== false ) :
   
       			if ( !empty( $entry[$field->id] ) ) :
   
       				if ( !function_exists('media_handle_upload') ) {
   
       					require_once(ABSPATH . "wp-admin" . '/includes/image.php');
       					require_once(ABSPATH . "wp-admin" . '/includes/file.php');
       					require_once(ABSPATH . "wp-admin" . '/includes/media.php');
   
       				}
   
       				$new_photo_url = $entry[$field->id];
   
       				$new_photo_src = media_sideload_image( $new_photo_url, 0, null, 'src' );
   
       				if ( !is_wp_error( $new_photo_url ) ) :
   
       					global $current_user;
   
       					get_currentuserinfo();
   
       					update_user_meta( $current_user->ID, 'cupp_meta', '' );
       					update_user_meta( $current_user->ID, 'cupp_upload_meta', $new_photo_src );
       					update_user_meta( $current_user->ID, 'cupp_upload_edit_meta', '' );
   
       				endif;
   
       			endif;
   
       		endif;
   
       	endforeach;
   
       }
       ```
   
 *  [alohadavid](https://wordpress.org/support/users/alohadavid/)
 * (@alohadavid)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/upload-photo-using-gravity-forms-user-registration/#post-6542674)
 * I would love to have this too!! 🙂

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Upload photo using Gravity Forms User Registration’ is closed to new 
replies.

 * ![](https://s.w.org/plugins/geopattern-icon/custom-user-profile-photo_e4e4e4.
   svg)
 * [Custom User Profile Photo](https://wordpress.org/plugins/custom-user-profile-photo/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/custom-user-profile-photo/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/custom-user-profile-photo/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-user-profile-photo/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-user-profile-photo/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-user-profile-photo/reviews/)

 * 6 replies
 * 6 participants
 * Last reply from: [alohadavid](https://wordpress.org/support/users/alohadavid/)
 * Last activity: [10 years, 1 month ago](https://wordpress.org/support/topic/upload-photo-using-gravity-forms-user-registration/#post-6542674)
 * Status: not resolved