-
Author
-
July 5, 2017 at 15:49 #166376
internetservice
Participanthi support, I am trying to know where is the code that regulates search button in the front page is located?
because I am trying to hide search button for free user and only display them to paid user. I wanted to put this code in the function of search button
`if( !current_user_can( ‘manage_options’) ){
if( !pmpro_hasMembershipLevel() ){ return; }
}`
I already disabled bp search function using the above code but it seems for the search button on the frontpage uses different code setup. so can you tell me where it is located?
Attachments:
You must be logged in to view attached files.July 5, 2017 at 18:32 #166419Laura
ModeratorHello, will assign the ticket to a higher support level who can help and advise you in your query.
Thanks! ?Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionLaura Solanes - Graphic Designer and Web Designer
Please be patient as I try to answer each topic as fast as i can.
If you like the theme or the support you've received please consider leaving us a review on Themeforest!
Always happy to help you 🙂
July 6, 2017 at 20:12 #166571Radu
ModeratorHi,
This it’s the function that render that button
COPY CODEif(!function_exists('kleo_search_menu_item')) { /** * Add search to menu * @param string $items * @param oject $args * @return string */ function kleo_search_menu_item ( $items, $args ) { if ($args->theme_location == 'primary') { ob_start(); get_template_part('page-parts/header-ajaxsearch'); $form = ob_get_clean(); $items .= '<li id="nav-menu-item-search" class="menu-item kleo-menu-item-search"><a class="search-trigger" href="#"><i class="icon icon-search"></i></a>'.$form.'</li>'; } return $items; } }
Just place the
COPY CODE$items .= '<li id="nav-menu-item-search" class="menu-item kleo-menu-item-search"><a class="search-trigger" href="#"><i class="icon icon-search"></i></a>'.$form.'</li>';
Into your condition and that’s all
Paste the code into child theme functions.php from wp-content/themes/kleo-child/functions.php
Cheers
RHi there!!! Help others from the community and mark any reply as solution if it solved your question. Ticket solutionJuly 7, 2017 at 18:59 #166674Radu
ModeratorYou’re welcome
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionFebruary 19, 2019 at 05:59 #218845ersalabert
ParticipantHi
I don’t know PHP, and I’m wondering if you could show where to add the $item code-snippet into the function provided by @Internetuser?
Thanks in advance.
February 19, 2019 at 15:11 #218868Radu
ModeratorHi,
The technical solution it’s there : https://archived.seventhqueen.com/forums/topic/where-is-search-button-code-located/#post-166571
So using that snippet and placing
COPY CODE$items .= '<li id="nav-menu-item-search" class="menu-item kleo-menu-item-search"><a class="search-trigger" href="#"><i class="icon icon-search"></i></a>'.$form.'</li>';
Into next condition :
COPY CODEif( !current_user_can( ‘manage_options’) ){ if( !pmpro_hasMembershipLevel() ){ return; //code here } }
So the final code will looks like this
COPY CODEif(!function_exists('kleo_search_menu_item')) { /** * Add search to menu * @param string $items * @param oject $args * @return string */ function kleo_search_menu_item ( $items, $args ) { if ($args->theme_location == 'primary') { ob_start(); get_template_part('page-parts/header-ajaxsearch'); $form = ob_get_clean(); if( !current_user_can( 'manage_options') and pmpro_hasMembershipLevel() ) { $items .= '<li id="nav-menu-item-search" class="menu-item kleo-menu-item-search"><a class="search-trigger" href="#"><i class="icon icon-search"></i></a>'.$form.'</li>'; } } return $items; } }
Cheers
RHi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution -
AuthorPosts
You must be logged in to reply to this topic.