Advertisement
ghenzdeveloper

Change Mycred Display name

Aug 7th, 2023
1,499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1. add_filter( 'mycred_parse_tags_user', function ( $content, $user, $data ) {
  2.  
  3.     if ( ! is_object( $user ) && is_array( $user ) )
  4.         $user = (object) $user;
  5.  
  6.     if ( ! isset( $user->ID ) ) return $content;
  7.  
  8.     $profile_url = mycred_get_users_profile_url( $user->ID );
  9.     $display_name = $user->display_name;
  10.  
  11.     if(class_exists('PeepSoUser')){
  12.         $peepso_user = PeepSoUser::get_instance($user->ID);
  13.         $display_name = $peepso_user->get_fullname();
  14.     }
  15.  
  16.     $content     = str_replace( '%user_profile_link%',  '<a href="' . esc_url_raw( $profile_url ) . '">' . esc_attr( $display_name ) . '</a>', $content );
  17.  
  18.     return $content;
  19.  
  20. }, 10, 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement