apply_filters( 'relevanssi_user_add_data', $user )
This filter lets you manipulate the user object before Relevanssi indexes the user.
Parameters
$user
(WP_User) The user object.
More information
When Relevanssi Premium indexes a user profile, the WP_User
object first goes through this filter hook. This hook allows you to manipulate the object. If you need to index some outside data for each user, this hook lets you add in the data. You can also use this hook to alter or remove some existing data from the users.
Relevanssi indexes user meta fields, description, first and last name, and display name. Modifying any other fields does not affect the outcome. If you need to add new content to the user profiles, add it to the description
field.
For example, to add the contents of the column user_data
from the database table wp_user_extra_data
to the description, you could do this:
add_filter( 'relevanssi_user_add_data', function( $user ) { global $wpdb; $data = $wpdb->get_var( $wpdb->prepare( "SELECT user_data FROM wp_user_extra_data WHERE user_id = %d", $user->ID ) ); if ( $data ) { $user->description = $data; } return $user; } );