Facetwp User Post Type featured image

FacetWP User Post Type Addon v0.8

Developer: FacetWPCategory: WordPress PluginsTrusted with 43 downloadsProLatest v0.8Updated 1y ago

This plugin lets you connect WP users to a post type, so that you can create user listings, and filter users with facets like any other post type.

Same brand

More from FacetWP

Facetwp icon

Facetwp

by FacetWP

Use FacetWP to add faceted search to your eCommerce sites, resource libraries, s...

Facetwp Submit Button icon

Facetwp Submit Button

by FacetWP

Add a submit button that redirects to a separate results page We often get asked...

Facetwp Multilingual Addon icon

Facetwp Multilingual Addon

by FacetWP

If you are using WPML, Polylang or Polylang Pro, download and install the Multil...

Related items

Related Filter Plugins

Filter Everything Pro icon

Filter Everything Pro

by FilterEverything.Pro

Filter Everything — WordPress & WooCommerce product filter plugin, that allows t...

Search & Filter Pro – The Ultimate Wordpress Filter Plugin (addons included) icon

Search & Filter Pro – The Ultimate Wordpress Filter Plugin (addons included)

by DesignsAndCode

The Ultimate WordPress Filter Plugin

WooCommerce Product Filter Pro icon

WooCommerce Product Filter Pro

by WooBeWoo

Create and customize filters for your online store using Free WooCommerce Produc...

This plugin lets you connect WP users to a post type, so that you can create user listings, and filter users with facets like any other post type. How it works FacetWP can only index and filter posts (of any (custom) post type). However, WP users are not a post type, so users cannot be filtered directly. To make users filterable by FacetWP, this add-on creates a new (hidden) upt_user custom post type, and creates a post for each WP user by syncing WP users to upt_user posts. Sync all default and custom user fields. The add-on’s settings also let you sync user field data to the new upt_user posts. This data can then be used to: Display (custom) user field data in a user listing Use a (custom) user field as a facet data source to filter a user listing Use a (custom) user field in a meta_query in a user listing query. The synced user data consists of the default user data that is available for each WP user, but also custom (user) fields that you added yourself. The add-on supports custom fields made with WP hooks, with Advanced Custom Fields and with BuddyPress. See the section below to learn how to create custom user fields. The upt_user custom post type is not directly visible in the WP admin menu, but you can still access the menu item directly to see and check all synced users and their custom fields. Or you can force the admin menu item to appear. Getting started Download Download the add-on from your account and install it as a plugin. Setup Here is a short video on how to set up the add-on: Selecting a custom user field. Sync all default and custom user fields. After installing and activating the add-on, browse to Settings > User Post Type and click the “Sync now” button. As seen in the image on the right, you can also sync extra custom user fields (other than the default user fields) to the upt_user posts. Syncing is not required to display that custom field data or to use those custom fields as a facet’s data source. Syncing extra custom user fields is only useful/needed if you use these fields in a meta_query in a custom WP_Query, as demonstrated in the example below. If needed (to clear up any issues, or to make sure there is no stray unsynced data), you can click the “Reset” button, which wipes out all UPT User posts and all synced post data. Clicking “Sync now” will then recreate all posts and sync all selected user fields. Here’s a list of dropdown choices and corresponding meta_query keys: Option Meta Key User ID ID User Login user_login User Email user_email User URL user_url Registration Date user_registered User Status user_status Display Name display_name Roles roles Usermeta field meta-[fieldname]Fields made with with WP hooks or with Advanced Custom Fields are prefixed with meta- when synced. This means that the field name to use in a custom meta query is meta-[fieldname], e.g. meta-my_user_field. See the example below. BuddyPress field bp-[fieldID]Fields made with BuddyPress are stored by their BuddyPress field ID and are prefixed with bp- when synced. This means that the field name to use in a custom meta query is bp-[fieldID]. To find the field ID in BuddyPress, edit the field in Users -> Profile Fields, and check the URL for the field_id parameter, e.g. &field_id=2. In this example, this field will be synced/stored as bp-2. How to see and check synced users and custom user fields The hidden upt_user custom post type that this add-on generates is not directly visible in the WP admin menu. If you prefer to always see it, you can force the UPT Users admin menu item to appear. Or you can access the upt_user post list screen directly, by using this URL: https://yourdomain.com/wp-admin/edit.php?post_type=upt_user The (hidden) UPT Users overview screen. Use “Edit” to see the custom user fields. Hover over “View” to see the WP user ID in the /user-x/ URL in the browser’s status bar at the bottom. In the UPT Users post list screen, you can see all synced users as individual posts. These upt_user posts have a post URL ending in /user-x/, where x corresponds with the WP user ID. If needed, you can use this ID to check for discrepancies after syncing. This post URL can be seen in the browser’s status bar at the bottom, by hovering over the “View” link under the post item, as shown in the image on the right. If you click the “Edit” link of a upt_user post/user, you can also see all synced custom fields and their values. Warning:Do not edit (or add) upt_user posts or their custom fields directly in their post edit admin pages. Any changes will be overwritten or deleted in the next UPT sync/delete. Make any changes to users (and their custom fields) in their WP user profile pages, and let the sync take care of the rest. If the Custom Fields metabox does not show up in the individual post edit screens, you probably have Advanced Custom Fields installed, which by default hides this metabox. To enable the metabox, add the following ACF hook to your (child) theme’s functions.php: How to use custom PHP code?PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More infoadd_filter( 'acf/settings/remove_wp_meta_box', function( $remove ) { if ( ! is_admin() || ! function_exists( 'get_current_screen' ) ) { return $remove; } $screen = get_current_screen(); if ( $screen->base === 'post' && $screen->post_type === 'upt_user' ) { return false; // Re-enable the Custom Fields metabox } return $remove; }, 20 ); How to create and use custom user fields Custom user fields can be created in several ways. The User Post Type add-on supports syncing any usermeta field created with WP hooks, with Advanced Custom Fields and with BuddyPress. To create and use custom user fields, follow these steps: 1. Create a custom user field Where to create custom user fields If you want to add custom fields to users, it is important to add these fields to the WP user profile itself, and not to the (hidden) upt_user post type that the add-on creates and syncs to. If you would attach a custom field to the upt_user post type, the data would be wiped out on each reset and sync that is performed in UPT User settings, or when saving the WP user profile (which also performs an automatic sync). So, as a general rule: don’t add fields to, or edit data directly in upt_user posts. Always, add/edit the data to/in the WP user profile, and let the sync take care of the rest. How to create custom user fields with Advanced Custom Fields To create a custom WP user field with Advanced Custom Fields, first create a field group for your user field(s) and set its “Location Rules” to “User Form -> is equal to -> All”, as shown in the image below. This will make sure the field is attached to the WP users and will show up in the WP user profile pages. Next, create your custom field in this field group, e.g. my_user_status: How to create a custom user field with Advanced Custom Fields. It’s important to attach the field group to WP user profile, as shown above, and not to the upt_user post type like in the image below. If you’d connect the field to the upt_user post type, its data would be wiped out on each reset and sync that is performed in the UPT User settings, or when saving the WP user profile (which also performs an automatic sync). Do not attach the user field group to the upt_user post type. How to create custom user fields with BuddyPress BuddyPress lets you add custom user field groups and user fields under Users -> Profile Fields: Creating custom field in BuddyPress, under Users -> Profile Fields. These fields will then show up in an “Extended Profile” tab on each WP user profile page. How to create custom user fields with WP hooks We recommend using Advanced Custom Fields to create custom user fields. But you can also do it without plugins, with WP hooks. The following example creates a “Phone Number” field (with the field name phone_number) in each WP user profile page, under a “Extra Profile Information” heading: How to use custom PHP code?PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More info/** * Show custom user profile fields * * @param WP_User $user The WP_User object. */ function my_show_extra_profile_fields( $user ) { ?>


User Post Type. Optionally, you can first click “Reset”, which deletes all upt_user posts and wipes their data, which will be recreated on sync. Find your new custom user field name in the dropdown. For each field name, you’ll also see one prefixed with an underscore (e.g. _my_user_status), which you can ignore. Select the one without the underscore, click Save, then click the blue “Sync now” button. Note that BuddyPress fields will show up as [fieldgroup] fieldname at the bottom of the dropdown. When the sync has completed successfully, you’ll see “Sync complete”. If needed, you can check the resulting UPT User posts and their custom field values in their post edit screens as explained above. Query all users To display a list of all users, use WP_Query (not WP_User_Query ) like so: How to use custom PHP code?PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More info$args = [ 'post_type' => 'upt_user', 'post_status' => 'publish', 'posts_per_page' => 10, ]; $query = new WP_Query( $args ); You can also use a Listing Builder listing, or for more elaborate queries, a Listing Builder listing in Dev mode, as shown below. Query a subset of users To query a subset of users, you need to create a custom WP_Query that uses meta_query to filter by existing user fields or by custom user fields. Query users by existing user fields with a meta query To display only administrators, select “Roles” in the settings page dropdown, then click the blue “Sync now” button. Then you can use the roles field within meta_query: How to use custom PHP code?PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More info$args = [ 'post_type' => 'upt_user', 'post_status' => 'publish', 'orderby' => [ 'title' => 'ASC' ], 'posts_per_page' => 30, 'meta_query' => [ [ 'key' => 'roles', 'value' => 'administrator', 'compare' => '=', ] ] ]; $query = new WP_Query( $args ); To do the same with multiple roles, in this example administrators and editors: How to use custom PHP code?PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More info$args = [ 'post_type' => 'upt_user', 'post_status' => 'publish', 'orderby' => [ 'title' => 'ASC' ], 'posts_per_page' => 30, 'meta_query' => [ [ 'key' => 'roles', 'value' => [ 'administrator', 'editor' ], 'compare' => 'IN', ] ] ]; $query = new WP_Query( $args ); Query users by one or more custom user fields with a meta query To use a custom user field in a meta_query argument in a upt_user listing query, you must use the synced upt_user post field, and not the WP user field. This also means that syncing that field is required for the meta_query to work. The field name to use in the meta_query must include the prefix with which the field is synced/stored in upt_user postmeta. For fields made with WP hooks or Advanced Custom Fields, the synced field name is prefixed with meta-, e.g. meta-my_user_field. For BuddyPress fields, the fields are synced by the field ID and prefixed with bp-. To find the field ID in BuddyPress, edit the field in Users -> Profile Fields, and check the URL for the field_id parameter, e.g. &field_id=2. In this example, this field will be synced/stored as bp-2. As an example, say you want to give users a custom “user status” field, and you want to display a user listing that excludes users with a specific status. To demonstrate using multiple meta queries, let’s also exclude users with the role “practitioner”. To accomplish this, let’s first create the custom status field and attach it to WP’s user profile page. Using Advanced Custom Fields, create a field group for your user field(s) and set its “Location Rules” to “User Form -> is equal to -> All”, as shown in the image below. Next, create a new custom field in this field group, e.g. my_user_status. You can add more fields later. How to create a custom user field with Advanced Custom Fields. Note:In this example we are using my_user_status as field name to make a point: user_status is an already existing field name in WP. Always make sure that a custom field name does not already exist. You can see existing names in the User Post Type settings dropdown. Next, make sure all WP user profile pages are saved after adding the new field. If the field does not exist for the user, it cannot be synced, and it will not be available in the corresponding upt_user post’s postmeta. Querying by a non-existent field will result in no posts showing up in the listing. Selecting a custom user field. Sync all default and custom user fields. To sync the new user field, go to Settings > User Post Type. Optionally, you can click “Reset”, which deletes all upt_user posts and wipes their data, which will be recreated on sync. Find the field name my_user_status (and any other field you created). For each field name, you’ll also see one prefixed with an underscore (e.g. _my_user_status), which you can ignore. Select the one without the underscore, click Save, then click the blue “Sync now” button. When the sync has completed successfully, you’ll see “Sync complete”. The new custom field values are now available in the upt_user posts’ postmeta. They are ready to be used in a meta_query argument when querying the upt_user post type, as demonstrated below. If needed, you can check the resulting UPT User posts and their custom field values in their post edit screens as explained above. Now let’s create a user listing with a query that uses the new my_user_status field. In the following example, we’ll use the Listing Builder in Dev mode, but you can do this in any other listing template type. Create a new Listing Builder listing and set the “Display” tab to display whatever user data you want. For testing, just use “Display Name” or “Post Title” (which both output the user name). In the “Query” tab, enable “Dev mode” in the top right, and paste the following query arguments: How to use custom PHP code?PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More info ['upt_user'], 'post_status' => ['publish'], 'meta_query' => [ 'relation' => 'AND', // The relation if you use multiple meta queries. Possible values: 'AND' or 'OR'. [ 'key' => 'roles', // Roles is an existing WP field 'compare' => 'NOT IN', // Field EXISTS and value is NOT IN ... 'value' => ['practitioner'], // array of values 'type' => 'CHAR', ], [ 'key' => 'meta-my_user_status', // IMPORTANT: Use meta-[fieldname] and make sure the field is synced in UPT settings 'compare' => 'NOT IN', // Field EXISTS and value is NOT IN ... 'value' => ['expired'], // array of values 'type' => 'CHAR', ] ], 'orderby' => 'meta_value', // Order by the meta key specified in 'meta_key' 'meta_key' => 'display_name', // The meta key to sort by 'order' => 'ASC', // Order A-Z 'posts_per_page' => 20 // Show 20 posts per page ]; In the above example we retrieve upt_user posts that do NOT have the practioner role AND for which the my_user_status field the value is NOT expired. We order the listing by the user display_name, in ascending order (A-Z), and retrieve 20 posts per page. Important to notice is that in line 14 we use meta-my_user_status as key, and not my_user_status. This is because when syncing WP user fields (made with Advanced Custom Fields or with WP hooks) to the upt_user post type, all field names are prefixed with meta-. For BuddyPress fields, the fields are synced/stored by the BuddyPress field ID and prefixed with bp-. See above for how to find the field IDs. If the meta_query does not work, the most probable reasons are: You did not sync the field. You synced the wrong field (e.g. the one prefixed with an underscore). The newly created field name already exists in WP. The WP users are not saved after creating the new field. The field is not populated for any WP user, which results in nothing being synced. You used the un-prefixed field name in the meta_query argument. The name needs to be prefixed with meta-, as shown in line 14 above. (BuddyPress fields are stored by their BuddyPress field ID and prefixed with bp-). Display (custom) user fields in a user listing To display (custom) user fields/data in a user listing, best practice is to look up the actual WP user metadata/fields and display that, instead of the synced upt_user posts’ metadata/fields. You could get and output the synced field connected to the upt_user post (which has its name prefixed with meta-). This will work, but it’s recommended to always use the WP user field to prevent issues with the field not being present after a reset or a problematic sync. This also means that as long as you use the custom WP user field itself, syncing the field is not needed to display custom user field data in a user listing. To retrieve and display WP users’ metadata you can use WP’s get_user_meta() function. Just replace $user_id with UPT()->get_user_id(): How to use custom PHP code?PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More infoecho get_user_meta( UPT()->get_user_id(), 'your_field_name', true ); Outside of The Loop, pass in the post ID like so: How to use custom PHP code?PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More infoecho get_user_meta( UPT()->get_user_id( THE_POST_ID ), 'your_field_name', true ); Display the user avatar To get a user’s photo, you can use WP’s get_avatar() function, assuming that the image is stored in WP’s default “Profile Picture” field: How to use custom PHP code?PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More infoecho get_avatar( UPT()->get_user_id(), 150 ); // 150 is the height and width of the avatar in pixels. Add facets that filter by a (custom) user field You can use any facet type to filter users by a (custom) user field. After creating a new facet, in the facet’s Data Source setting, you can either choose the custom WP user field itself, or the synced field connected to the upt_user post (which has its name prefixed with meta-). Both will work, but it’s recommended to always use the WP user field, to prevent issues with the field not being present after a reset or a problematic sync. This also means that as long as you use the custom WP user field itself as data source, syncing the field is not needed to use a custom user field in a facet. When the User Post Type add-on is installed, you’ll see a “User Fields” section in the Data source dropdown under which all default WP user fields are listed. Custom fields are listed at the bottom, twice. Make sure to choose the field that does not have its name prefixed with an _ underscore. If the custom user field was made with Advanced Custom Fields, it will also appear under the “ACF” heading in the Data Source dropdown, prefixed with its field group between square brackets. Customize which users are synced With the upt_sync_where and upt_sync_skip_user hooks, you can customize which users are being synced, as shown in the examples below. Important:After adding or changing code that uses the upt_sync_where or upt_sync_skip_user hook, make sure to click “Reset”, then “Sync now” in the UPT settings, to clear out existing users. Otherwise, the users that are being skipped will remain as upt_user posts, without getting updated when syncing. Sync only specific users To sync only users with a specific user ID, you can use the upt_sync_where hook. The following example syncs only users with ID’s 9, 10 and 11: How to use custom PHP code?PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More infoadd_filter( 'upt_sync_where', function( $where ) { $where .= ' AND u.ID IN (9, 10, 11)'; // sync only user IDs 9, 10 and 11. return $where; }); Prevent a specific user from being synced To prevent a specific user from being synced, use the following code and set the user’s ID in line 2: How to use custom PHP code?PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More infoadd_filter( 'upt_sync_skip_user', function( $bool, $user_id ) { if ( 1 === $user_id ) { // Skip user with ID 1 return true; } return $bool; }, 10, 2 ); Prevent users with specific roles from being synced To prevent users with a specific role from being synced, you can use the following snippet. Change the roles to be skipped in the array in line 3. How to use custom PHP code?PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More infoadd_filter( 'upt_sync_skip_user', function( $bool, $user_id ) { $roles = (array) get_user_by( 'ID', $user_id )->roles; $roles_to_skip = [ 'dormant-student', 'dormant-teacher' ]; // Skip these roles foreach ( $roles_to_skip as $role ) { if ( in_array( $role, $roles ) ) { return true; // Skip this user } } return $bool; }, 10, 2 ); This also works for custom user roles made with a plugin, like for example User Role Editor. You can also do the opposite: Only sync users with a specific role To sync only users with a specific role, you can use the following snippet. Change the roles to be synced in the array in line 3. How to use custom PHP code?PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More infoadd_filter( 'upt_sync_skip_user', function( $bool, $user_id ) { $roles = (array) get_user_by( 'ID', $user_id )->roles; $roles_to_preserve = [ 'student','teacher' ]; // Sync only these roles $intersect = array_intersect( $roles, $roles_to_preserve ); if ( empty( $intersect ) ) { return true; // Skip users not in $roles_to_preserve } return $bool; }, 10, 2 ); Programmatically sync users To programmatically sync a single user, use the following in your code or hook. Pass in the WP user ID in $user_id: How to use custom PHP code?PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More infoUPT()->sync->run_sync( $user_id ); To programmatically sync all users, use the following: How to use custom PHP code?PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More infoUPT()->sync->run_sync(); Note that users are already synced automatically when their profile is updated from the standard WP admin user profile edit page. Updating the user profile triggers WordPress’ profile_update action hook that the User Post Type add-on uses to trigger the sync. Programmatically syncing users is only needed if you are using custom code or a plugin that updates user fields without running the profile_update action hook. You could check the plugin for a hook that fires after the user update is completed, and use that hook to trigger the sync. Another way is to use the updated_user_meta hook (see: updated_{$meta_type}_meta) that fires after updating usermeta data. The following example performs a user sync when the basic_user_avatar field is updated (when using the Basic User Avatars plugin). Note that for this to work, the field (basic_user_avatar in this case) first needs to be synced in the UPT Users settings. How to use custom PHP code?PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More infoadd_action( 'updated_user_meta', function( $meta_id, $user_id, $meta_key, $meta_value ) { if ( 'basic_user_avatar' === $meta_key ) { UPT()->sync->run_sync( $user_id ); } }, 100, 4 ); Programmatically sync users on a schedule The following example creates a cron job that performs an automatic user sync every 8 hours: How to use custom PHP code?PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More infoadd_action( 'mysite_sync_users', 'mysite_sync_users_callback' ); function mysite_sync_users_callback() { UPT()->sync->run_sync(); } if ( ! wp_next_scheduled( 'mysite_sync_users' ) ) { wp_schedule_single_event( time() + 28800, 'mysite_sync_users' ); // 28800 seconds = every 8 hours } Perform post-sync actions To do something when the user sync has completed, you can use the upt_sync_post hook, which runs for each WP user being synced. The $user_id is the ID of the WP user being synced, and the $post_id is the ID of the corresponding upt_post post it is being synced to. How to use custom PHP code?PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More infoadd_action( 'upt_sync_post', function( $post_id, $user_id ) { // $post_id is the synced upt_user post ID // $user_id is the WP user ID if ( $post_id == 2345 ) { // do something after upt_user post with ID 2345 is synced } if ( $user_id == 3 ) { // do something after WP user with ID 3 is synced } }, 10, 2 ); Find a user’s associated upt_user post Use the following if you have a WP user’s $user_id and want to find the $post_id of the associated upt_user post: How to use custom PHP code?PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More info$post_id = (int) get_user_meta( $user_id, UPT()->meta_key, true ); Customize register_post_type arguments for the upt_user post type You can use the upt_post_type_args hook to customize any arguments of the register_post_type function, when the upt_user post type is registered. Two examples: Force the admin menu item to appear To force the “UPT Users” admin menu item to appear: How to use custom PHP code?PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More infoadd_filter( 'upt_post_type_args', function( $args ) { $args['show_in_menu'] = true; return $args; }); If the Custom Fields metabox does not show up in the individual post edit screens, you probably have Advanced Custom Fields installed, which by default hides this metabox. To enable the metabox, add the following ACF hook to your (child) theme’s functions.php: How to use custom PHP code?PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More infoadd_filter( 'acf/settings/remove_wp_meta_box', function( $remove ) { if ( ! is_admin() || ! function_exists( 'get_current_screen' ) ) { return $remove; } $screen = get_current_screen(); if ( $screen->base === 'post' && $screen->post_type === 'upt_user' ) { return false; // Re-enable the Custom Fields metabox } return $remove; }, 20 ); Warning:Do not edit (or add) upt_user posts or their custom fields directly in their post edit admin page. Any changes will be overwritten in the next UPT sync. Make any changes to users (and their custom fields) in their WP user profile pages. Prevent single upt_user posts from being visible Set the publicly_queryable argument to false to prevent the single posts from the upt_user post type from being accessed on the front-end (via for example https://yourdomain.com/upt_user/user-1/): How to use custom PHP code?PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More infoadd_filter( 'upt_post_type_args', function( $args ) { $args['publicly_queryable'] = false; return $args; }); Customize user field choices The upt_user_choices hook can be used to add or remove items from the list of usermeta fields that appear in the UPT User dropdown to sync, and in all facets’ Data Source dropdown (under the “User Fields” heading). Adding fields this way would only be useful if these fields are not stored like normal usermeta, e.g. in plugins or custom code that stores them another way. You can see a usage example of this hook in user-post-type/includes/class-buddypress.php. Note that $choices is an associative array of key-value pairs, in which all non-default (non-WP) user fields are stored as 'meta-fieldname' => 'fieldname', where each fieldname in the key is prefixed with meta-: How to use custom PHP code?PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More infoadd_filter( 'upt_user_choices', function( $choices ) { // Add or remove user fields from the UPT User dropdown and facet data source dropdowns (under the User Fields section heading). // E.g. $key ='my_custom_user_field'; $choices['meta-$key'] = $key; return $choices; } ); Customize access to the settings If you need to give certain user roles access to the User Post Type add-on settings, you can use the upt_admin_settings_capability hook. To change access to the main FacetWP plugin settings and other add-ons, you can use the facetwp_admin_settings_capability hook. Using User Post Type with Relevanssi or SearchWP Say you have a listing that retrieves users and want to use a Search facet with a SearchWP or Relevanssi search engine. To make this work, you’ll have to make sure that: SearchWP/Relevanssi is indexing the upt_user post type. all user fields you want the user listing searched by are synced to upt_user post meta fields in the add-on’s settings. these synced upt_user post meta fields are indexed by SearchWP/Relevanssi. Changelog 0.8.1Dec 16, 2024 New added `upt_admin_settings_capability` hook 0.8Aug 19, 2024 Fixed adjust sync priority to improve 3rd party compatibility 0.7.8Feb 26, 2024 Fixed PHP 8.2 deprecation notices Fixed potential name conflict when re-indexing 0.7.7Feb 23, 2022 Fixed issue preventing value of "0" from getting indexed 0.7.6Nov 2, 2021 Important Go into `Settings > User Post Type` and hit the "Sync" button Fixed issue causing a new meta row to get added on each user save 0.7.5Sep 10, 2021 Fixed sync issues (prevents needing to manually re-sync in many cases) 0.7.4Jun 8, 2021 New added `upt_sync_where` hook to customize the SQL WHERE clause 0.7.3Oct 29, 2020 New added multisite support (only sync users of the current site) See also Indexing What are facets? The upt_admin_settings_capability hook Using FacetWP with Advanced Custom Fields Using the Listing Builder in Dev Mode The Search facet type Using FacetWP with SearchWP Using FacetWP with Relevanssi Last updated: October 7, 2025

Recent releases

Release history

View all 2 versions
v0.8Latest
Feb 15, 202519.4 KB
v0.7.3
Oct 2, 202329.1 KB

Frequently asked questions

Is Facetwp User Post Type GPL licensed?
Yes, Facetwp User Post Type is distributed under the GNU General Public License (GPL). You can legally use, modify, and redistribute it on unlimited websites.
Can I use Facetwp User Post Type on multiple websites?
Yes. Under the GPL license, there are no domain or site restrictions. You can install Facetwp User Post Type on as many websites as you need.
How much does Facetwp User Post Type cost on GPLCoffee?
Facetwp User Post Type is available for $5.99 for a 1-year license or $15.99 for a lifetime license. Membership plans also include credit-based access so you can download Facetwp User Post Type along with thousands of other plugins for a single subscription.
Are updates included with Facetwp User Post Type?
Yes. Every new release of Facetwp User Post Type is synced to GPLCoffee automatically. You can download the latest version any time, and subscribers can use the one-click connector plugin to update directly from their WordPress dashboard.
Is Facetwp User Post Type safe to download?
Every Facetwp User Post Type release is scanned with VirusTotal before publication. Scan results (including the specific threat report URL when available) are visible on each version page, and releases flagged as malicious are blocked from the catalog.

Auto-updates included

Install it once, update automatically.

The GPLC Connector installs this plugin from your wp-admin and rolls out new versions to your connected sites - up to 25. Included with 12-month and Geek Lifetime plans (plus legacy 6-month).