Using Gravity Forms ‘gform_author_dropdown_args’ PHP filter

The gform_author_dropdown_args filter allows you to modify the list of authors displayed in the author dropdown selection for Post Fields in the Gravity Forms form editor.

Usage

To apply the filter to all forms:

add_filter('gform_author_dropdown_args', 'set_users');

To apply the filter to a specific form, like form ID 5:

add_filter('gform_author_dropdown_args_5', 'set_users');

Parameters

  • $args (array): The arguments to be filtered, in the format expected by the wp_dropdown_users() WordPress function.

More information

See Gravity Forms Docs: gform_author_dropdown_args

Examples

Include specific users (IDs 1 and 8)

This code will modify the author dropdown to display only users with IDs 1 and 8.

add_filter('gform_author_dropdown_args', 'set_users');

function set_users($args) {
    $args['include'] = '1,8';
    return $args;
}

Exclude specific users (IDs 2 and 3)

This code will modify the author dropdown to exclude users with IDs 2 and 3.

add_filter('gform_author_dropdown_args', 'exclude_users');

function exclude_users($args) {
    $args['exclude'] = '2,3';
    return $args;
}

Display only administrators

This code will modify the author dropdown to display only users with the administrator role.

add_filter('gform_author_dropdown_args', 'show_admins_only');

function show_admins_only($args) {
    $args['role'] = 'administrator';
    return $args;
}

Order authors by display name

This code will modify the author dropdown to order authors by their display name.

add_filter('gform_author_dropdown_args', 'order_by_display_name');

function order_by_display_name($args) {
    $args['orderby'] = 'display_name';
    return $args;
}

Limit authors to 10

This code will modify the author dropdown to display only 10 authors.

add_filter('gform_author_dropdown_args', 'limit_authors');

function limit_authors($args) {
    $args['number'] = 10;
    return $args;
}

Place the code examples in the functions.php file of your active theme.