apply_filters ( 'jetpack_widget_authors_params', array $get_author_params )

Filter the parameters of `get_users` call in the Widget Authors widget.

Source file: modules/widgets/authors.php

View in GitHub

Parameters

$get_author_params

(array) Array of params used in get_user


Changelog

Since: Jetpack 7.7.0


Notes

See the following for get_users default arguments: https://codex.wordpress.org/Function_Reference/get_users

In the example below, we will use the filter to exclude author 1 from the widget, and order authors from the oldest registered to the newest:

function jetpackcom_order_authors_widget( $get_author_params ) {
    $get_author_params['exclude'] = array( 1 );
    $get_author_params['order']   = 'ASC';
    $get_author_params['orderby'] = 'registered';

    return $get_author_params;
}
add_filter( 'jetpack_widget_authors_params', 'jetpackcom_order_authors_widget' );

Have a note to contribute?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Comments

  1. Ahmet Usta says:

    This is great progress. I’m so happy to see that my request was considered and solved. On the other hand, I am not a coder neither a developer just someone who can manage copy paste codes 🙂

    May I ask you to share sample code to sort the authors by predefined IDs. For example, I have authors with IDs 1,3,4,5,7 and I excluded ID 1 with ‘jetpack_widget_authors_exclude parameter. Now I want to sort the rest authors in that order: 5-4-3-7

    Thanks

    • Jeremy Herve says:

      I added an example above to give you an example of how this can be used.

      You will not be able to order authors using an arbitrary order though: you’ll need to pick a way to order authors from the following list:
      ‘ID’, ‘login’, ‘nicename’, ’email’, ‘url’, ‘registered’, ‘display_name’, ‘post_count’, ‘include’, or ‘meta_value’.

      You can find out more about the different parameters you can use here:
      https://codex.wordpress.org/Function_Reference/get_users

      • Ahmet Usta says:

        Thank you very much Jeremy. I find out a way to solve my problem. E-mails of those users are not important, I will sort by email and assign the e-mails in an alphebitical order of I wish 🙂 JetPack has a great team