Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'get_avatar' , 'my_custom_avatar' , 1 , 5 );
- function my_custom_avatar( $avatar, $id_or_email, $size, $default, $alt ) {
- $user = false;
- if ( is_numeric( $id_or_email ) ) {
- $id = (int) $id_or_email;
- $user = get_user_by( 'id' , $id );
- } elseif ( is_object( $id_or_email ) ) {
- if ( ! empty( $id_or_email->user_id ) ) {
- $id = (int) $id_or_email->user_id;
- $user = get_user_by( 'id' , $id );
- }
- } else {
- $user = get_user_by( 'email', $id_or_email );
- }
- if ( $user && is_object( $user ) ) {
- $value = rwmb_meta( 'profile_picture', array( 'object_type' => 'user' ), $user->data->ID );
- if ( $value ) {
- $avatar = "<img src='" . $value['url'] . "' class='avatar avatar-" . $size . " photo' alt='" . $alt . "' height='" . $size . "' width='" . $size . "' />";
- }
- }
- return $avatar;
- }
- ?>
- <?php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement