All\r\n[authors_page]"; $UserRoles = get_roles(); foreach( $UserRoles as $RoleKey =>$RoleName ) { $Contents[] = "

$RoleName

\r\n[authors_page role=$RoleKey]"; } $Content = join("\r\n\r\n",$Contents); return $Content; } function uvd_aup_remove() { //$the_page_id = get_option('uvd_aup_page_id'); //wp_delete_post($the_page_id); delete_option('uvd_aup_page_id'); } function uvd_aup_render_authors_page( $role = null ) { global $wp_query; //set valid role $roles = get_roles_keys(); $role_lower = strtolower( $role ); $roles_lower = array_map('strtolower',$roles); if ( !in_array( $role_lower, $roles_lower ) ) $role = ''; $Permalink = get_permalink(); if (isset($wp_query->query_vars['author_login']) && $author = get_user_by('login',urldecode($wp_query->query_vars['author_login']))) { $ShowAuthorBiography = true; if( !empty( $role ) ) { $AuthorRoles = $author->roles; $AuthorRolesLower = array_map('strtolower',$AuthorRoles); if( !in_array($role_lower, $AuthorRolesLower )) $ShowAuthorBiography = false; } if( $ShowAuthorBiography ) { $Back .= '<<Back'; $html = $Back; $html .= do_shortcode( '[wp_biographia user='.urldecode($wp_query->query_vars['author_login']).']' ); return $html; } } $args = array( 'blog_id' => $GLOBALS['blog_id'], 'role' => $role, 'orderby' => 'post_count', 'order' => 'DESC', ); $authors = get_users( $args ); $clear_css = 'border:none; background:transparent; border:none; margin:0; padding:0;'; $html = '
'; $max_column_count = 4; $columns_count = 0; foreach ( $authors as $author) { $columns_count++; if ( $columns_count % $max_column_count == 1 ) { $html .= ''; } $html .= ''; //$html .= '' .get_avatar($author->ID).'
'.$author->display_name.'
'; if ( $columns_count % $max_column_count == 0 || $columns_count == sizeof($authors) ) { $html .= ''; } } $html .= '
'; $html .= '' .get_avatar($author->ID).'
'.$author->display_name.'
'; return $html; } add_filter('query_vars', 'my_add_query_vars'); function my_add_query_vars($public_query_vars ) { $public_query_vars[] = 'author_login'; return $public_query_vars; } add_shortcode( 'authors_page', 'uvd_aup_shortcode' ); function uvd_aup_shortcode( $atts ) { $role = isset( $atts['role']) ? $atts['role'] : null; return uvd_aup_render_authors_page( $role ); } function get_roles_keys() { $Roles = get_roles(); $RoleKeys = array_keys( $Roles ); return $RoleKeys; } function get_roles() { /** * @var WP_Roles */ global $wp_roles; if ( !isset( $wp_roles ) ) $wp_roles = new WP_Roles(); $Roles = $wp_roles->get_names(); return $Roles; }