Continue reading WooCommerce: Aelia Prices by Country product visibility

WooCommerce: Aelia Prices by Country product visibility

Aelia has a Prices by Country for WooCommerce plugin, which can adjust prices based on customer country and hide products unavailable in a specific country. Jason James shared a function that makes Relevanssi hide unavailable products in search: add_filter( ‘relevanssi_post_ok’, ‘relevanssi_aelia_compatibility’, 10, 2 ); function relevanssi_aelia_compatibility( $post_ok, $post_id ) {…

Read more WooCommerce: Aelia Prices by Country product visibility 0 Comment on WooCommerce: Aelia Prices by Country product visibility
Continue reading WP Download Manager

WP Download Manager

filter hooks that make it possible to access WP Download Manager files. Changing the attachment query The first one we need is relevanssi_get_attachment_posts_query, which is used to fetch the attachment posts for indexing. By default, Relevanssi looks for posts with the post type attachment, post status inherit and a suitable……) ) { $params[‘relevanssi’] = true; } return $params; } Access If your files have limited access, you need to limit the access in the search as well. That is also straightforward using the relevanssi_post_ok filter hook and the wpdm_user_has_access() function: add_filter( ‘relevanssi_post_ok’, ‘rlv_wpdmpro_access’, 10, 2 ); function rlv_wpdmpro_access( $ok,……MIME type. These all need to be changed, because the WP Download Manager posts have the post type wpdmpro, status of publish and no MIME type. The necessary filter function looks like this: add_filter( ‘relevanssi_get_attachment_posts_query’, ‘rlv_wpdmpro_query’ ); function rlv_wpdmpro_query( $query ) { return str_replace( “post_type = ‘attachment’ AND post_status =…

Read more WP Download Manager 0 Comment on WP Download Manager
Continue reading Events Calendar: Remove past events from search

Events Calendar: Remove past events from search

…is to do both. Blocking the events in indexing with relevanssi_indexing_restriction will keep the index lean and blocking the events in searching with relevanssi_post_ok will make sure past events will be removed immediately from the search results. These instructions apply to The Events Calendar plugin, which stores the event end……= false; } } return $status; } /** * Removes past events from indexing. * * @param array $restriction The MySQL restriction and an explanation. * * @return array The restriction set with event restriction included. */ function rlv_exclude_past_events( $restriction ) { global $wpdb; $restriction[‘mysql’] .= ” AND post.ID NOT…

Read more Events Calendar: Remove past events from search 6 Comments on Events Calendar: Remove past events from search
Continue reading Restricting the search for non-logged-in users

Restricting the search for non-logged-in users

…of regular get_post(), because user profiles are involved) and if the post type is not set to user, the function returns false and the post is not shown to the user. The code above requires Relevanssi Premium (and only makes sense with it, because you can’t search user profiles without…There was an interesting support question: I have website with logged-in users as well as non-logged-in users. The logged-in user should be able to search through everything on the website, but the non-logged-in users should only be able to search the user profiles. Is it at all possible to differentiate……} return $show; } Add this to your site. If the user is logged in (is_user_logged_in() returns true), nothing is done, and the posts are shown to the user as usual. If the user is not logged in, Relevanssi then fetches the post object using relevanssi_premium_get_post() (this is necessary instead…

Read more Restricting the search for non-logged-in users 3 Comments on Restricting the search for non-logged-in users
Continue reading bbPress: Private Groups support

bbPress: Private Groups support

Private Groups is a plugin that makes bbPress forum groups private. Relevanssi, however, doesn’t understand that privacy and will show those groups in the search results. Relevanssi has means to support this, however, with the help of the relevanssi_post_ok filter. Here’s some code from Mark Wass that makes the private……forum posts private in search. Add this code to the theme functions.php file. /** * Filter search results so that private forum posts are not displayed * to members who do not belong to the particular private group. */ add_filter( ‘relevanssi_post_ok’, ‘rlv_filter_private_forum_posts’, 11, 2 ); function rlv_filter_private_forum_posts( $post_ok, $post_id )……{ //Default user can view results $user_can_view = true; $post = get_post( $post_id ); //Get the post type $post_type = $post->post_type; //Get the forum id the post belongs to (Only if it’s a topic or reply) if ( ‘reply’ === $post_type || ‘topic’ === $post_type ) { $forum_id = private_groups_get_forum_id_from_post_id(…

Read more bbPress: Private Groups support 0 Comment on bbPress: Private Groups support
Continue reading Premium 1.14.5

Premium 1.14.5

Relevanssi Premium 1.14.5 is a recommended release, as it fixes significant bugs that caused failures when custom fields contained arrays and when front-end plugins created posts. Multisite users are happy to find out meta_query support has been added to multisite searches and the post type filters work better. Relevanssi had problems with plus signs in…

Read more Premium 1.14.5 1 Comment on Premium 1.14.5
Continue reading Indexing custom post statuses

Indexing custom post statuses

posts to users, using the relevanssi_post_ok filter hook: add_filter( ‘relevanssi_post_ok’, ‘rlv_allow_custom_status’, 11, 2 ); function rlv_allow_custom_status( $post_ok, $post_id ) { $status = relevanssi_get_post_status( $post_id ); if ( ‘new_status’ === $status ) { $post_ok = true; } return $post_ok; } With these functions, Relevanssi will now work with the status new_status….If you’re using custom post statuses, Relevanssi requires some tinkering. By default, Relevanssi only handles posts that are of status publish, pending, draft or private. Relevanssi has a filter that lets you add more statuses to the list of acceptable statuses for Relevanssi. Add this to your site: function rlv_add_status(……$status_array ) { $status_array[] = ‘new_status’; return $status_array; } add_filter( ‘relevanssi_valid_status’, ‘rlv_add_status’ ); add_filter( ‘relevanssi_valid_admin_status’, ‘rlv_add_status’ ); This function, added to the two filters, makes Relevanssi accept the status new_status. You also need to let search know that it’s ok to show these posts to users, using the relevanssi_post_ok filter…

Read more Indexing custom post statuses 4 Comments on Indexing custom post statuses
Continue reading Excluding protected posts

Excluding protected posts

A site I’m working with has a handful of “protected” posts (password required to view). For various reasons, we don’t want to show these in search results. While there is no excerpt shown, I’d prefer for people to not even know they exist. Relevanssi sees protected posts as public posts…

Read more Excluding protected posts 14 Comments on Excluding protected posts
Continue reading Premium 1.9

Premium 1.9

Finally, Relevanssi Premium 1.9! This version includes the new file structure, where most of the code has been removed from relevanssi.php and moved to various files in the lib directory. These lib files are common between Relevanssi and Relevanssi Premium, making maintaining the plugin much easier. All the bug fixes I’ve done for free Relevanssi…

Read more Premium 1.9 13 Comments on Premium 1.9