This is a developer’s reference of some of the hooks you can use with Users Insights. They are used to reprocess the output (filters) or to fire your own functions (actions). You can read more about using hooks in the WordPress Plugin API.

Disclaimer: Please note that the hooks listed on this page may be subject to change or removal in future updates of the plugin. Additionally, the improper use of some of the hooks might lead to inaccurate results. This document is for reference only and should be used at your own responsibility.

Table of contents

 

User data filters


 

  • usin_users_raw_data

Type: filter

Allows filtering the raw database results that are loaded in the user table, before the rows are converted to user objects. The filter passes an array of the database records that the main Users Insights table query returns. Each element in the array represents the corresponding database record for each user.

  • usin_user_db_data

Type: filter

Allows filtering the single user raw database data – works for both the user table and user profile section. This is useful if you need to format user data in a different format. Passes one argument with the entire data object.

The registered fields can be accessed as properties of the object (e.g.  $data->my_newfield ). Please note that the field data might not be always set due to the way the Users Insights query is designed to load only the fields that are needed. For example, if a particular field is hidden on the table and not being used in the current filters, the data for this field will not be loaded for performance reasons. That’s why when using this filter, make sure to first check that the corresponding field is set on the data object.

Example:

  • usin_single_user_db_data

Type: filter

Similar to the previous filter, it allows filtering the single user raw database data. But this time it works only in the user profile. The filter passes one argument with the entire user data object.

Example:

 

User profile filters


 

  • usin_user_profile_data

Type: filter

Allows modifying the user object data on the user profile page. This filter is similar to the  usin_single_user_db_data filter, the only difference is that this one passes the actual user object with all the default field formatting already applied.

  • usin_user_activity

Type: filter

Allows adding custom elements to activity section and filtering the ones you have. Passes two arguments, first the activity array and the user ID.

Each element in the activity array represents a separate activity (as an array). Allowed values in the activity array are:

  • type – unique identifier of the activity
  • label – the name/label of the activity
  • count – the number of activities that exist from this type
  • link – indicates the URL of the “View all” link. This link is displayed when there are more activities from this type than the ones that are currently shown
  • list – a list of activity items. Each item should be an array that should contain a title and a link. In the case of a high number of activity items, we recommend only loading the last few and setting a “View all” link in the link option where all of the items can be previewed.

Example:

  • usin_user_actions

Type: filter

Allows adding new buttons at the top of the user profile section. Useful for quick user actions, such as checking their profile in one of your plugins.

Users insights profile actions

Passes two arguments – an array with the default actions and the user id.

Example:

  • usin_notes_list

Type: filter

Allows filtering the notes list for a user. Passes an array of the notes list.

 

Database query filters


 

The following section describes some of the main database query filters that you might need to modify the user query of Users Insights. These can be useful if you need to restrict the results of the users displayed.

  • usin_user_query_select

Type: filter

Allows you to modify the SELECT statement of the final user query, after it is built. Passes a string with the original query select. This filter is applied to the SELECT statement of both the user table and user profile.

  • usin_query_where

Type: filter

Allows setting a custom WHERE statement of the main query, after it is built. Passes a string of the original where argument. This filter is applied to the WHERE statement of both the user table and user profile query.

This field should not be used for applying a WHERE clause to your custom registered fields, but rather to apply a default filter to the main query.

  • usin_query_having

Type: filter

Allows setting a custom “having” statement of the main query. Passes a string of the original having argument. This filter is applied to the HAVING statement of both the user table and user profile query.

  • usin_query_joins

Type: filter

Modifies the main query JOIN clause. Passes a string with the original JOINS. Similarly to the above-mentioned filters, this one is also applied to both the user table and profile queries.

If you want to register a JOIN statement for your custom field, use the  usin_query_join_table filter instead, which is only applied when the field is visible on the table or used in the filters.

 

Privacy filters


 

  • usin_personal_data_erase_exclude_custom_fields

Type: filter

This filter allows you to exclude the Users Insights custom fields to erase upon a Personal Data Erase request. The filter passes an array with the default field keys that will not be erased (by default it’s an empty array).

In this way, if you use custom fields with Users Insights that do not store personal data, but you need to keep when the user sends a Personal Data Erase request, you can use this filter to make sure these fields are not erased.

  • usin_detect_user

Type: filter

This filter allows skipping user detection. If you want to disable the geolocation detection, last seen/sessions detection or device detection for a particular user, you can use this filter to do that. This filter passes two arguments – a boolean that indicates whether the user information should be detected and the user ID as an integer:

Example:

 

3rd party plugin filters


 

  • usin_ignore_um_types

Type: filter

Allows changing the default Ultimate Member field types that are ignored by Users Insights (such as “row” or “divider”). Passes the array with the types that Users Insights ignores by default.

  • usin_add_profile_link_to_order

Type: filter

Allows removing the Users Insights profile link from the WooCommerce order page. Passes a boolean which defaults to  true . If you’d like to remove the link, just return  false from the filter callback.

 

Additional filters


  • usin_fields

Type: filter

Modifies the available Users Insights fields. By default, this array contains the default Users Insights fields and the fields you have mapped under Users Insights > Custom fields. You can use this filter to remove or edit the existing fields.

Passes an array of the default fields, containing an array of each field’s attributes.

Example – removing the email field:

  • usin_wp_user_meta_core_keys

Type: filter

By default Users Insights doesn’t allow registering a custom field with a meta key that is used by WordPress core. With this filter you can modify the list of core keys that Users Insights checks against. This filter passes an array with the default WordPress core keys.

  • usin_group_colors

Type: filter

This filter allows you to customize the Users Insights group colors. Passes an array with the default options.

Here is an example of how to add new colors:

  • usin_exclude_comment_types

Type: filter

This filter allows you to modify the default comment types are ignored in the Users Insights table (number of comments field) and in the user profile (comments listed in the Activity section). Passes an array with the comment type names.

  • usin_exclude_post_types

Type: filter

This filter allows you to modify the default post types are ignored in the Users Insights table (number of posts field) and in the user profile (posts listed in the Activity section). Passes an array with the custom post type names.

  • usin_module_options

Type: filter

Allows to modify the list of the Users Insights modiules. Passes an array with all the registered modules – each item in the array is another array containing the module options.

This is an example of how the module options array looks like:

  • usin_client_ip

Type: filter

This filter allows changing the method used to collect the user’s IP address for the GeoLocation module. Passes the user’s IP address that was collected by the default Users Insights method.

  • usin_user_list_options

Type: filter

This filter contains a lot of JavaScript initialization options for the main Users Insights page, and it can be used for a lot of interface tweaks. Passes an array with the default options.

Here is an example of adding another option for the number of users to show per page:

  • usin_max_report_items

Type: filter

This filter can be used to edit the number of bars or pie chart elements shown before being grouped in an “Other” section. Passes an integer with the value we have.

 

Users Insights actions


 

  • usin_files_loaded

Type: Action

This action is fired after the Users Insights files/classes are loaded.

  • usin_loaded

Type: Action

This action is fired after Users Insights is initialized.

  • usin_module_options_loaded

Type: Action

This action is fired after the module options are loaded.

  • usin_module_activated

Type: Action

This action is fired when a module is activated. It passes the ID of the module activated.

  • usin_module_deactivated

Type: Action

This action is fired when a module is deactivated. It passes the ID of the module activated.