This would be useful for me as well! Thanks!
Thread Starter
tystra
(@tystra)
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!
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
I would love to have this too.
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;
}
I would love to have this too!! 🙂