Skip to content

Relevanssi

  • Buy Premium
  • Download
  • Features
  • User manual
  • Knowledge Base
  • Support
  • Contact
Knowledge Base > Plugin compatibility > Profile Builder Pro
Posted on April 13, 2015March 11, 2022

Profile Builder Pro

by Mikko Saari

Relevanssi can index extra fields created with Profile Builder Pro. All you need to do is add the custom fields’ names to the Relevanssi setting “User fields to index” (this is a Premium feature, so you need to have Relevanssi Premium). You can find the names of the fields from the Profile Builder > Manage Fields page: use the value in the “Meta Name” column.

Relevanssi doesn’t know how to use the extra fields in excerpts. This code adds all indexed fields to the user profile content before Relevanssi builds the excerpts using the relevanssi_pre_excerpt_content filter hook:

add_filter( 'relevanssi_pre_excerpt_content', 'rlv_profile_builder', 10, 2 );
function rlv_profile_builder( $content, $post ) {
    if ( isset( $post->user_id ) ) {
        $fields = get_option( 'relevanssi_index_user_fields' );
        if ( !empty( $fields ) ) {
            $fields_array = explode( ',', $fields );
            foreach( $fields_array as $user_field ) {
                $field_content = get_user_meta( $post->user_id, $user_field, true );
                $content .= ' ' . $field_content;
            }
        }
    }
    return $content;
}

Permalinks are another problem. By default, the permalinks in search results point to the site front page. Switching the permalinks on the theme search results template to use relevanssi_get_permalink() instead of get_permalink() or the_permalink() will help a bit, but not enough: now the links point to the WordPress user profile pages. However, Profile Builder Pro profile pages will use a different URL structure. Another filter function on the relevanssi_user_profile_to_post is needed:

add_filter( 'relevanssi_user_profile_to_post', 'rlv_adjust_url' );
function rlv_adjust_url( $user ) {
    $user->link = '/url/to/user/' . $user->user_id . '/';
    return $user;
}

Change the /url/to/user/ to match the URL structure used on your site. This change requires you to use relevanssi_get_permalink() to display the permalinks, the_permalink() or get_permalink() will not work.

Profiles created by Profile Builder Pro front end forms do not get automatically indexed by Relevanssi because the user account generation process in Profile Builder Pro doesn’t probably trigger all the filter hooks WP does. Thus Relevanssi overlooks the new user profiles Profile Builder Pro generates.

Profile Builder Pro has an action hook that you can use to nudge Relevanssi a bit. Add this code to your site, and Relevanssi will notice the new users and will index them:

add_action( 'wppb_register_success', 'rlv_index_wppb_users', 20, 3 );
function rlv_index_wppb_users( $http_request, $form_name, $user_id ){
    relevanssi_index_user( $user_id, false );
}

Related Posts

User profile search

Relevanssi Premium can search user profiles. So far the following data gets indexed from user profiles: first name, last name, display name and description. If you're interested in having something el...

Divi

Make Divi include all post types Divi search form module restricts the search to only posts and pages. To get rid of that restriction, you can add this to your site: add_action( 'pre_get_posts',...

Premium 1.10

The beta testers had no complaints, so here goes: Relevanssi Premium 1.10 and a ton of updates. Made some changes to how user profiles and taxonomy terms are handled. As a result, there should be l...

Index custom field contents

Custom fields (also known as post meta or meta fields) are a major part of WordPress the default search won't search. That's a big problem for people who use solutions like Advanced Custom Fields or C...

ACF: Indexing ACF fields for taxonomy terms

Advanced Custom Fields makes it possible to add custom fields to taxonomy terms. You can only do this with Relevanssi Premium because the free version of Relevanssi can't index taxonomy terms. Here...

Indexing only attributes from shortcodes

I need to add some custom shortcodes to the list of the “removed” ones (so they don’t show in plain text in the results).However, some of them are built like [shortcode_name text="Need to keep th...

Categories: Plugin compatibility
Tags: plugin compatibility, Profile Builder Pro, relevanssi_pre_excerpt_content, relevanssi_user_profile_to_post

Leave a Reply Cancel reply

Are you a Relevanssi Premium customer looking for support? Please use the Premium support form.

Your email address will not be published. Required fields are marked *

Buy Premium

Buy now »

(for other license options, see here)

License status

Not logged in. Log in to see your license details.




Search

When autocomplete results are available use up and down arrows to review and enter to go to the desired page. Touch device users, explore by touch or with swipe gestures.

Recent Posts

  • Integrating Post Views Counter stats
  • Premium 2.27 / Free 4.24 release notes
  • Premium 2.26 / Free 4.23 release notes
  • GeneratePress: Query Loop
  • Year filter from the search query
  • Pin a post for all searches
  • WooCommerce: Aelia Prices by Country product visibility
  • PublishPress Revisions: duplicate posts
  • Korean postpositions
  • Premium 2.25 / Free 4.22 release notes
  • Indexing attachments from File blocks
  • Premium 2.24 / Free 4.21
  • EmbedPress autoembeds
  • Premium 2.23 / Free 4.20
  • WooCommerce: Make Relevanssi notice stock changes

Post navigation

Previous Previous post: Genesis
Next Next post: Free 3.4

Relevanssi

WordPress search done right!

The free version

Relevanssi at WP.org plugin repository
Relevanssi at Github

Relevanssi Light

Relevanssi Light
Relevanssi Light at WP.org plugin repository
Relevanssi Light at Github

Relevanssi Live Ajax Search

Relevanssi Live Ajax Search
Relevanssi Live Ajax Search at WP.org plugin repository
Relevanssi Live Ajax Search at Github

Responsibility

We take corporate responsibility and our environmental impact seriously. Read our responsibility statement.

Code from Finland
  • Github
  • WordPress.org
Copyright 2024 Mikko Saari and Painava sana oy. Privacy policy. Cookie declaration.