iamkeef This is for security reasons.
What kind of security reasons are these? CommandUI does not allow anybody to do things they are not allowed to do via their WordPress permissions. WordPress validates everything, CommandUI calls core endpoints via the rest api + some internal endpoints that are all permission adjusted.
In any case, you can use this snippet.
/**
* Prevents CommandUI from loading the main JS in the frontend,
* only if the current user ID is the specified hardcoded one.
*/
add_filter('commandui/load-js', function() {
// Replace with the your account user ID
$target_user_id = 1;
// Get the current WordPress user ID
$current_user_id = get_current_user_id();
// Return true if the current user ID matches the hardcoded one, otherwise false.
return $current_user_id === $target_user_id;
});