Skip to content

Hooks reference ​

Hooks of the free plugin. The Pro add-on is built on them, so it is a good example of how to extend the plugin.

Hooks with since 2.5.0 or later need that version of the plugin; check WPUBDP_ADDON_API (an integer, increased when hooks are added) if your code must run with older versions.

ubdwp_filter_types ​

filter since 2.5.0

Adds filter types to Choose filter type. A type added here shows the form rows with the class ubdwp-filter-type-{type} and finds its users with ubdwp_custom_filter_user_ids. The built-in types cannot be removed.

ParameterTypeDescription
$typesarray<string, string>Type labels keyed by type

See Adding a filter type for a complete example.

ubdwp_custom_filter_user_ids ​

filter since 2.5.0

Returns the users found by a filter type added with ubdwp_filter_types. Users that are not members of the current site are ignored.

ParameterTypeDescription
$user_idsarray<int>|WP_Error|nullUser IDs, an error, or null when the type is not handled
$typestringFilter type
$requestarray<string, mixed>Raw request data (unslashed, not sanitized)
$current_user_idintUser running the search

ubdwp_found_user_ids ​

filter since 2.4.0

Narrows the users found by the filters, for example to apply extra filters of another plugin. The result can only be narrowed: IDs that were not found are ignored.

ParameterTypeDescription
$user_idsarray<int>User IDs found
$typestringFilter type
$requestarray<string, mixed>Raw request data (unslashed, not sanitized)
php
// Never delete users who have a "vip" user meta.
add_filter( 'ubdwp_found_user_ids', function ( $user_ids ) {
	return array_values( array_filter( $user_ids, fn( $id ) => ! get_user_meta( $id, 'vip', true ) ) );
} );

ubdwp_selected_user_ids ​

filter since 2.5.0

Changes the users chosen in Choose from existing users, for example to add users of a list. Users that are not members of the current site are ignored.

ParameterTypeDescription
$user_idsarray<int>User IDs chosen in the form
$requestarray<string, mixed>Raw request data (unslashed, not sanitized)

ubdwp_search_error ​

filter since 2.5.0

Filters the validation error of a search. Return null to accept it, for example when at_least_one_required is reported but the request has criteria of your plugin. Register messages of new error codes with ubdwp_error_messages.

ParameterTypeDescription
$errorstring|nullError code, or null when the search is valid
$typestringFilter type
$requestarray<string, mixed>Request data: fields of the plugin are sanitized, other fields are raw

ubdwp_error_messages ​

filter since 2.5.0

Messages of error codes the plugin does not know, for example codes of an add-on.

ParameterTypeDescription
$messagesarray<string, string>Translated plain-text messages keyed by error code

ubdwp_preview_limit ​

filter since 2.3.0

Maximum number of users one preview can contain. Default 0 (no limit).

Filter form ​

All of these are actions that print table rows (<tr>). Give a row the class of a filter type (ubdwp-filter-existing, ubdwp-filter-find, ubdwp-filter-woocommerce, or ubdwp-filter-type-{type} for an added type) and style="display: none;" to show it only for that type. The fields are sent with the preview request; read them in ubdwp_found_user_ids or ubdwp_custom_filter_user_ids.

ActionSinceWhere it prints
ubdwp_filter_form_top2.5.0Top of the form, before the filter type selector; rows for every type
ubdwp_filter_form_fields2.4.0After the filter fields, inside the form table
ubdwp_find_fields_account2.5.0End of the Account group of "Find users according to certain criteria"
ubdwp_find_fields_activity2.5.0End of the Activity group
ubdwp_find_fields_spam2.5.0End of the Spam signs group
ubdwp_find_fields_fraud2.5.0End of the Fraud signals group (shown only when something is hooked)
ubdwp_find_fields_advanced2.5.0End of the Advanced group
ubdwp_filter_form_buttons2.5.0After the Preview button (buttons)

Deletion ​

ubdwp_is_protected_user ​

filter since 2.3.0

Whether a user is protected from deletion. Administrators, users who can manage other users and super admins are protected by default. Since 2.6.0, users protected by this filter who are not privileged themselves are shown with the reason excluded from deletion by your settings.

ParameterTypeDescription
$protectedboolWhether the user is protected
$userWP_UserUser being checked
$current_user_idintUser performing the deletion
php
// Protect every user with the "editor" role.
add_filter( 'ubdwp_is_protected_user', function ( $protected, $user ) {
	return $protected || in_array( 'editor', (array) $user->roles, true );
}, 10, 2 );

ubdwp_before_delete_user ​

action since 2.4.0

Fires before a user is deleted (or removed from the site on multisite), while the user and their content still exist.

ParameterTypeDescription
$user_idintUser ID
$reassignint|stringUser ID that receives the content, remove_all_related_content, or "" for the WordPress default
$userWP_UserThe user

ubdwp_user_deleted ​

action since 2.4.0

Fires after a user was deleted or removed from the site. The entry contains the full email and name, before the privacy setting of the log is applied.

ParameterTypeDescription
$user_idintUser ID
$entryarrayuser_id, email, display_name, reassign, action (deleted or removed_from_site)

ubdwp_job_created ​

action since 2.4.0

Fires after a deletion job was created, before it is summarized and confirmed. $job is the job row (ID, user_id, status, mode, total, user_ids, …).

ubdwp_job_finished ​

action since 2.4.0

Fires when a job is completed, cancelled or failed.

ParameterTypeDescription
$statusarray<string, mixed>Job status, as shown on the admin page: job_id, owner_id, status, mode, total, deleted, failed, summary, failed_users, …
$jobobjectJob row

Limits ​

FilterSinceDefaultDescription
ubdwp_confirmation_threshold2.3.020From this number of users, the number must be typed to confirm
ubdwp_delete_batch_size2.4.050Users deleted per batch (1–500)
ubdwp_background_time_budget2.4.0up to 20Seconds one background run may spend deleting (5–120)

ubdwp_confirm_texts ​

filter since 2.5.0

The warnings shown before users are deleted, for example to say they can be restored. $texts has the keys typing, plain and cli; typing and cli contain %d for the number of users.

Export ​

ubdwp_export_columns ​

filter since 2.5.0

Columns of the CSV export of selected users. Add columns here and fill them with ubdwp_export_row. The built-in columns cannot be removed.

ParameterTypeDescription
$columnsarray<string, string>Column headers keyed by column
$formatstringreadable, or import for importers (headers are field or meta names). Since 2.6.0.

ubdwp_export_row ​

filter since 2.5.0

Values of a user in the CSV export, keyed by column.

ParameterTypeDescription
$rowarray<string, mixed>Values keyed by column
$userWP_UserUser
$columnsarray<string, string>Column headers keyed by column
php
// Add the billing country to the export.
add_filter( 'ubdwp_export_columns', function ( $columns, $format ) {
	$columns['billing_country'] = 'import' === $format ? 'billing_country' : 'Billing country';
	return $columns;
}, 10, 2 );

add_filter( 'ubdwp_export_row', function ( $row, $user ) {
	$row['billing_country'] = get_user_meta( $user->ID, 'billing_country', true );
	return $row;
}, 10, 2 );

Admin pages ​

HookTypeSinceDescription
ubdwp_settings_tabsfilter2.5.0( $tabs ) tabs of the Settings page; general is the plugin's own tab
ubdwp_settings_tabaction2.5.0( $tab ) print the content of an added tab
ubdwp_settings_pageaction2.4.0Add sections at the end of the General tab
ubdwp_logs_page_actionsaction2.5.0Print buttons above the Logs table
ubdwp_plugin_pagesfilter2.5.0( $pages ) page slugs that load the plugin styles and scripts and hide notices of other plugins
ubdwp_keep_admin_noticefilter2.5.0( $keep, $callback ) keep a notice of another plugin on the plugin pages

The free plugin is released under the GPL v2 or later. The Pro add-on is sold through Freemius.