I have these two codes I am trying to combine.
<?php
$args2 = array(
'role' => 'fotograf',
'orderby' => 'user_nicename',
'order' => 'ASC'
);
$authors = get_users($args2);
echo '<ul>';
foreach ($authors as $user) {
echo '<li><p>' . $user->display_name.'<br>'.$user->user_email . '</p></li>';
}
echo '</ul>';
?>
<?php
//list each role and each user with that role
global $wp_roles;
foreach( $wp_roles->role_names as $role => $name ) {
$name = translate_with_context($name);
echo '<p>List of users in the role '.$role .' ('. $name . '):</p>';
$this_role = "'[[:<:]]".$role."[[:>:]]'";
$query = "SELECT * FROM $wpdb->users WHERE ID = ANY (SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'wp_capabilities' AND meta_value RLIKE $this_role) ORDER BY user_nicename ASC LIMIT 10000";
$users_of_this_role = $wpdb->get_results($query);
if ($users_of_this_role) {
foreach($users_of_this_role as $user) {
$curuser = get_userdata($user->ID);
$author_post_url=get_author_posts_url($curuser->ID, $curuser->nicename);
echo '<p> <a href="' . $author_post_url . '" title="' . sprintf( __( "Posts by %s" ), $curuser->user_nicename ) . '" ' . '>' . $curuser->display_name .'</a></p>';
}
}
}
?>