Archived topic
Search in Menu Bar for logged in users only?
4 replies · Started by Michael on June 18, 2018
Viewing posts 1–5 of 5
Hi,
The search bar in the navigation is perfect, but is there a way I can only display it to logged in users?
Reason being it has been used for spam searches, and that counts towards my allowance of the facility. So I only want it displayed for members.
Thanks for any help
Hi Michael,
Try this function:
add_action( 'wp', 'tu_disable_guest_nav_search' );
function tu_disable_guest_nav_search() {
if ( ! is_user_logged_in() ) {
remove_filter( 'wp_nav_menu_items', 'generate_menu_search_icon', 10, 2 );
remove_action( 'generate_inside_navigation', 'generate_navigation_search' );
}
}
Let me know :)
Hi Tom,
Muchas Gracias :)
I'll try it out and report back.
Works like a charm, thank you :)
Awesome, glad I could help! :)
This archived topic is closed to new replies.