Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
Created May 1, 2020 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgibbs189/dc7af6acacfe14dddd7320ec5702b0d3 to your computer and use it in GitHub Desktop.
Save mgibbs189/dc7af6acacfe14dddd7320ec5702b0d3 to your computer and use it in GitHub Desktop.
FacetWP - User Post Type - re-index whenever a user is saved
<?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 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment