Skip to content

Instantly share code, notes, and snippets.

@yuriinalivaiko
Last active February 6, 2025 17:31
Show Gist options
  • Save yuriinalivaiko/7c2c6f931fcf94cd472a38a6e0c675d6 to your computer and use it in GitHub Desktop.
Save yuriinalivaiko/7c2c6f931fcf94cd472a38a6e0c675d6 to your computer and use it in GitHub Desktop.
Ultimate Member customization. Disable content restriction for searching.
<?php
// Disable content restriction for searching.
add_action( 'wp_loaded', function() {
if ( ( is_search() || isset( $_GET['s'] ) ) && function_exists( 'UM' ) ) {
remove_action( 'template_redirect', array( UM()->access(), 'template_redirect' ), 1000 );
remove_action( 'pre_get_terms', array( UM()->access(), 'exclude_hidden_terms_query' ), 99 );
remove_filter( 'widget_posts_args', array( UM()->access(), 'exclude_restricted_posts_widget' ), 99 );
remove_filter( 'wp_list_pages_excludes', array( UM()->access(), 'exclude_restricted_pages' ) );
remove_filter( 'getarchives_where', array( UM()->access(), 'exclude_restricted_posts_archives_widget' ), 99 );
remove_filter( 'get_next_post_where', array( UM()->access(), 'exclude_navigation_posts' ), 99 );
remove_filter( 'get_previous_post_where', array( UM()->access(), 'exclude_navigation_posts' ), 99 );
remove_action( 'pre_get_posts', array( UM()->access(), 'exclude_posts' ), 99 );
remove_filter( 'posts_where', array( UM()->access(), 'exclude_posts_where' ) );
remove_filter( 'wp_count_posts', array( UM()->access(), 'custom_count_posts_handler' ), 99 );
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment