This topic has 6 replies, 4 voices, and was last updated 5 years by Radu.

  • Author
  • #166376
     internetservice
    Participant

    hi 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.
    #166419
     Laura
    Moderator

    Hello, 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 solution

    Laura 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 🙂

    #166571
     Radu
    Moderator

    Hi,

    This it’s the function that render that button

    COPY CODE
    
    
    if(!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
    R

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Ticket solution
    #166573
     internetservice
    Participant

    yes, thank you for the code explanation. 🙂

    #166674
     Radu
    Moderator

    You’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 solution
    #218845
     ersalabert
    Participant

    Hi

    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.

    #218868
     Radu
    Moderator

    Hi,

    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 CODE
    if( !current_user_can( ‘manage_options’) ){
    
    if( !pmpro_hasMembershipLevel() ){ 
    
    return;
    //code here
    } 
    
    }

    So the final code will looks like this

    COPY CODE
    
    if(!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
    R

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

Log in with your credentials

Forgot your details?