我将发布必须在函数中的整个代码。php这是合法的WP有效代码,应该如何做:)这应该可以工作,当然你必须把你的角色名放在switch中。
UPDATED FOR PERFORMANCE:
add_action( \'show_user_profile\', \'user_fields_for_admin\', 10);
add_action( \'edit_user_profile\', \'user_fields_for_admin\', 10);
function user_fields_for_admin( $user ){
switch ($user->roles[0]) {
case \'SOME ROLE\':
echo \'<b>This is the role specific fields</b>\';
echo \'fields....\';
break;
case \'SOME ANOTHER ROLE\':
echo \'<b>This is the role specific fields</b>\';
echo \'fields....\';
break;
}
}