Skip to content

Commit ae4635c

Browse files
authored
gfur-set-wp-default-profile-picture.php: Created new snippet.
1 parent e573bb3 commit ae4635c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
/**
3+
* Gravity Forms // User Registration // Setting WordPress Default Profile Picture
4+
* https://gravitywiz.com/
5+
*
6+
* Video: https://www.loom.com/share/e36fe58e7b8740248d287e9492c0ee7a
7+
*/
8+
add_filter( 'pre_get_avatar', function( $avatar, $id_or_email, $args ) {
9+
// Update "profile_picture" to whatever custom field (e.g. user meta) you will be saving the profile picture to.
10+
$profile_picture = get_user_meta( $id_or_email, 'profile_picture', true );
11+
if ( $profile_picture ) {
12+
$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'] );
13+
add_filter( 'user_profile_picture_description', '__return_false' );
14+
}
15+
return $avatar;
16+
}, 10, 3 );

0 commit comments

Comments
 (0)