Advertisement
Guest User

Untitled

a guest
Feb 24th, 2022
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.93 KB | None | 0 0
  1. add_filter( 'get_avatar' , 'my_custom_avatar' , 1 , 5 );
  2. function my_custom_avatar( $avatar, $id_or_email, $size, $default, $alt ) {
  3.     $user = false;
  4.     if ( is_numeric( $id_or_email ) ) {
  5.         $id = (int) $id_or_email;
  6.         $user = get_user_by( 'id' , $id );
  7.     } elseif ( is_object( $id_or_email ) ) {
  8.         if ( ! empty( $id_or_email->user_id ) ) {
  9.             $id = (int) $id_or_email->user_id;
  10.             $user = get_user_by( 'id' , $id );
  11.         }
  12.     } else {
  13.         $user = get_user_by( 'email', $id_or_email );
  14.     }
  15.  
  16.     if ( $user && is_object( $user ) ) {
  17.         $value = rwmb_meta( 'profile_picture', array( 'object_type' => 'user' ), $user->data->ID );
  18.         if ( $value ) {
  19.             $avatar = "<img src='" . $value['url'] . "' class='avatar avatar-" . $size . " photo' alt='" . $alt . "' height='" . $size . "' width='" . $size . "' />";
  20.         }
  21.     }    
  22.     return $avatar;
  23. }
  24. ?>
  25. <?php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement