Setting WordPress Default Profile Picture



Filename: gfur-set-wp-default-profile-picture.php

 * Gravity Forms // User Registration // Setting WordPress Default Profile Picture
 * Video:
add_filter( 'pre_get_avatar', function( $avatar, $id_or_email, $args ) {
	// Update "profile_picture" to whatever custom field (e.g. user meta) you will be saving the profile picture to.
	$profile_picture = get_user_meta( $id_or_email, 'profile_picture', true );
	if ( $profile_picture ) {
		$avatar = sprintf( '<img alt="" src="%s" class="avatar avatar-64 photo" height="%d" width="%d" loading="%s" decoding="%s">', $profile_picture, $args['width'], $args['height'], $args['loading'], $args['decoding'] );
		add_filter( 'user_profile_picture_description', '__return_false' );
	return $avatar;
}, 10, 3 );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.