Wordpress Change Default Display Name Publicy As for all existing users

前端 未结 6 601
耶瑟儿~
耶瑟儿~ 2021-02-05 23:58

does anyone know of way I can change the existing display name publicly as for all users. I want to have firstname lastname as the default because this will reflect in the forum

6条回答
  •  野性不改
    2021-02-06 00:24

    use this code in function.php this code juste for change display_name and replace with first_name plus first letter for last_name in step the new user or update info for user .

    //Change the publicly displayed name on comments
    	add_filter('pre_user_display_name','default_display_name');
    		function default_display_name($name) {
    			 global $current_user;
         		 get_currentuserinfo();
    			
    		 $lastname=mb_substr($current_user->user_lastname, 0, 1, "UTF-8");
    			$name =  ucfirst($current_user->user_firstname) .' '.ucfirst($lastname). '.';
    			return $name;
    		}

提交回复
热议问题