you can use paginate_links() from wordpress core API, its make more easily to paginate your custom query. And you dont need to make another query to get all users count.
<?php
$users_per_page = 10; // total no of author to display
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
if( (int)$paged === 1 ){
$offset = 0;
} else {
$offset = ($paged-1) * $users_per_page;
}
$args = array(
'meta_key' => 'location',
'number' => $users_per_page,
'offset' => $offset,
'meta_value' => $flow_location,
'meta_compare' => '=',
'role' => 'admin',
'orderby' => 'ID',
'order' => 'DESC'
);
$fields = array('fields' => 'all_with_meta');
$user_query_subs = new WP_User_Query( $args, $fields );
$users = $user_query_subs->get_results();
if ( !empty( $users ) ) {
foreach ( $users as $user ) {
// code goes here
}
}
else {
echo 'No flowers found.';
}
?>
And then the pagination, remember it depends on how your structure is.
If you use permalinks, then you can use this code below:
<?php
$query_string = $_SERVER['QUERY_STRING']; // current query parameters
$total_users = $user_query_subs->total_users; // total number of users
$total_pages = ceil( $total_user/$users_per_page ); // total number of pages
// if on the front end, your base is the current page
$base = get_permalink( get_the_ID() ) . '?' . remove_query_arg('paged', $query_string) . '%_%';
$paginate_args = array(
'base' => $base,
'format' => '?paged=%#%', // define the query parameter that will be used, in this case "paged"
'current' => $paged,
'total' => $total_pages,
'prev_text' => 'Previous',
'next_text' => 'Next' ,
'end_size' => 1,
'mid_size' => 5
);
echo paginate_links($paginate_args);
?>