Created
May 1, 2020 19:29
-
-
Save mgibbs189/dc7af6acacfe14dddd7320ec5702b0d3 to your computer and use it in GitHub Desktop.
FacetWP - User Post Type - re-index whenever a user is saved
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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