• Hello,
    the function user_list of PT_CV_Values retrieve all users, including subscribers. It should get authors, editors and administrators only (with a filter for custom roles).
    Furthermore, user_login is not in the result.

    Proposition :
    $result=array();
    $show = ‘display_name’;
    $roles = array(‘administrator’,’editor’,’author’);
    $roles = apply_filters(PT_CV_PREFIX_.’author_roles’,$roles);
    $args = array(
    ‘fields’ => array( ‘ID’, ‘user_login’, $show ),
    ‘orderby’ => ‘display_name’,
    ‘order’ => ‘ASC’,
    ‘role__in’ => $roles
    );

    $users = get_users( $args );
    foreach ( (array) $users as $user ) {
    $user->ID = (int) $user->ID;
    $display = !empty( $user->$show ) ? $user->$show : ‘(‘ . $user->user_login . ‘)’;

    $result[ $user->ID ] = esc_html( $display );
    }

    • This topic was modified 8 years, 1 month ago by olidac.
    • This topic was modified 8 years, 1 month ago by olidac.
Viewing 1 replies (of 1 total)
  • Plugin Author Content Views

    (@pt-guy)

    Hello,
    In next version, we will add a filter to customize the parameters array for user_list() function, so you can add role__in.

    Best regards,

Viewing 1 replies (of 1 total)
  • The topic ‘PT_CV_Values user_list’ is closed to new replies.