How To Disable Add new users On Subsites In Multisite?

To remove the Add Users capability from Administrators (but leave it intact for Super Administrators), you can do this:

<?php
$role = get_role( 'administrator' );
if ( $role->capabilities['add_user'] == 1 && ! is_main_site( get_current_blog_id() ) ) {
// Because this is saved to the database, we check first
// to see if it's already been done
    $role->remove_cap['add_user'];
}
?>

Add the code to a plugin in the mu-plugins directory to have it run on each site (whenever the site in question is visited).

Note — this will remove the capability in the database. To restore it, you’ll need to use add_cap().

Reference

get_role()
remove_cap()
add_cap()
is_main_site()
get_current_blog_id()

error code: 523