Skip to content

Relevanssi

  • Buy Premium
  • Download
  • Features
  • User manual
  • Knowledge Base
  • Support
  • Contact
  • Testimonials
Knowledge Base > Plugin compatibility > Profile Builder Pro
Posted on April 13, 2015January 19, 2021

Profile Builder Pro

by Mikko Saari

Relevanssi can index extra fields created with Profile Builder Pro. All you need to do is to add the names of the custom fields 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 excerpts are built:

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;
}

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 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;
}

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. This is because of the user account generation process in Profile Builder Pro doesn’t probably trigger all the filter hooks WP does, and thus Relevanssi doesn’t notice the new users are generated.

Profile Builder Pro has an action hook that can be used to nudge Relevanssi a bit. Just add this code to the theme functions.php, 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);
}

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

WooCommerce

Relevanssi is a fine tool to enhance your WooCommerce store. In order to get the most out of Relevanssi and WooCommerce, you need to make some adjustments: everything doesn't work perfectly straight o...

Privacy Policy

Update information This privacy policy was created May 18th, 2018. Most recent update was March 3rd, 2020. Who we are Our website address is: https://www.relevanssi.com/. The site is operated...

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...

Installing Relevanssi and adjusting the settings

Installing Relevanssi is simple. For free version, install the latest version of the plugin from WordPress.org plugin repository. For Premium, download the latest version from Relevanssi.com and...

Divi

Divi and Relevanssi Premium Divi has included a Relevanssi compatibility module from version 4.7 onwards. However, that compatibility module only looks for the free version of Relevanssi and does n...

WP Download Manager

WP Download Manager is a popular file management plugin for WordPress. It's unfortunately incompatible with Relevanssi attachment content reading out of the box, as Relevanssi expects the attachments ...

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

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Buy Premium

Buy now »

(for other license options, see here)

Login Status

You are not currently logged in.








» Lost your Password?

Search

Your API key

Not logged in.

Recent Posts

  • Why is a post type excluded from search?
  • WP Event Manager
  • Martfury
  • Adding direct links to outside pages to search results
  • Relevanssi breaks autoembeds on result pages
  • Premium 2.14 / Free 4.12
  • Elementor
  • Ultimate Member
  • Moving the admin search page
  • Premium 2.13 / Free 4.11
  • Forced phrase search with fallback
  • WP Download Manager
  • Searching for all descendants of a page
  • Premium 2.12 / Free 4.10
  • PSA: New ransom scam in town

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

Affiliate program

Join the Relevanssi Premium affiliate program. Earn 20 % commissions for all Relevanssi Premium sales.

Responsibility

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

Code from Finland

  • Facebook
  • Github
  • WordPress.org
Copyright 2021 Mikko Saari and Painava sana oy. Privacy policy.