FacetWP – User Post Type – re-index whenever a user is saved

mgibbs189

{{gist file=”functions.php” lang=”php”}}
<?php

/**
* This goes within a user save hook
*
* First, we run a UPT sync to copy the data into the wp_post* tables
* Then we re-index in FacetWP to capture the changes
*/

UPT()->sync->run_sync( $user_id );

$post_id = (int) get_user_meta( $user_id, UPT()->meta_key, true );

if ( 0 < $post_id ) {
FWP()->indexer->index( $post_id );
}

{{/gist}}