How can I default to all WordPress roles when parameter is not included in shortcode?

Try this:

function profile_counts($atts) {
    $atts = shortcode_atts( array(
        'metakey'   => '',
        'metavalue' => '',
        'userrole'  => '',
    ), $atts );

    $user_ids = get_users( array(
        'meta_key'    => $atts['metakey'],
        'meta_value'  => $atts['metavalue'],
        'role__in'    => wp_parse_list( $atts['userrole'] ),
        'fields'      => 'ID',  // retrieve just the IDs
        'count_total' => false, // no need for FOUND_ROWS()
    ) );

    return count( $user_ids );
}

Important points:

  • For multiple roles, you can use the role__in parameter.

  • You only need to call shortcode_atts() once.