Jump to content

Photo
* * * * * 1 votes

Hide menu from non members


  • Please log in to reply
14 replies to this topic

#11 jeky

jeky

    Level 2

  • Members
  • Level
  • 12 points
  • 29 posts
    • Gender:Male
    • Location:Tajikistan

Posted 05 December 2011 - 07:36 AM

thanks man )) any screen to see it how is it ?

#12 Anubis

Anubis

    Level 4

  • Members
  • Level
  • 109 points
  • 129 posts
    • Gender:Male
    • Location:United States


Users Awards

Posted 02 February 2012 - 04:28 AM

If you dont want to show menu to guests/non members then simply follow these steps.

1: open header.tpl
2: find

<ul> <li style="padding-left:10px;"><a href='user_home.php'>{lang_print id=645}</a></li>
       {* SHOW ANY PLUGIN MENU ITEMS *}
      
   {hook_foreach name=menu_main var=menu_main_args complete=menu_main_complete max=8}
     <li> <a href='{$menu_main_args.file}' >{lang_print id=$menu_main_args.title}</a></li>
 
   {/hook_foreach}
3: Replace it with
<div class='codemain'>{if $user->user_exists != 0}
     <ul> <li style="padding-left:10px;"><a href='home.php'>{lang_print id=645}</a></li>
       {* SHOW ANY PLUGIN MENU ITEMS *}
      
   {hook_foreach name=menu_main var=menu_main_args complete=menu_main_complete max=8}
     <li> <a href='{$menu_main_args.file}' >{lang_print id=$menu_main_args.title}</a></li>
 
   {/hook_foreach}
   {/if}
   </div>

4: Save & upload.

Thank You...


Why make it so complex for people, by adding in extra stuff. Simple solution. If you dont want people to be able to see any of your plugin buttons when not logged in.

Open header.tpl

Find:
{hook_foreach name=menu_main var=menu_main_args complete=menu_main_complete max

Add above:
{if $user->user_exists != 0}

Then below that you will see:
{/hook_foreach}

Add after:
{/if}

It is that simple....
Posted Image

#13 dritoch

dritoch

    Level 4

  • Members
  • Level
  • 42 points
  • 168 posts

Posted 20 June 2012 - 10:24 PM

Why make it so complex for people, by adding in extra stuff. Simple solution. If you dont want people to be able to see any of your plugin buttons when not logged in.

Open header.tpl

Find:

{hook_foreach name=menu_main var=menu_main_args complete=menu_main_complete max

Add above:
{if $user->user_exists != 0}

Then below that you will see:
{/hook_foreach}

Add after:
{/if}

It is that simple....


Ok, what if I just want to hide one particular menu... say for example Browse School menu? I just want logged in members to see that menu and hide it from unregistered?

Edited by dritoch, 20 June 2012 - 10:25 PM.


#14 varshaan

varshaan

    Level 2

  • Members
  • Level
  • 21 points
  • 27 posts
    • Gender:Male
    • Location:Bangalore
    • Software:SE 4.8.x

Posted 03 May 2017 - 04:35 AM

Ok, what if I just want to hide one particular menu... say for example Browse School menu? I just want logged in members to see that menu and hide it from unregistered?

Even I am looking for solution for this.



#15 varshaan

varshaan

    Level 2

  • Members
  • Level
  • 21 points
  • 27 posts
    • Gender:Male
    • Location:Bangalore
    • Software:SE 4.8.x

Posted 19 September 2017 - 03:20 PM

I have worked out this issue in this way :

 

Adding menu initialize in plugins folder
 
 
class Yourmodule_Plugin_Menus {
   
    public function onMenuInitialize_Yourmodule() {
        $viewer = Engine_Api::_() -> user() -> getViewer();
        // Must be logged-in
        if ($viewer->level_id == 4 || $viewer->level_id == 5) { // put checks like this for each level id - for now its commented
            return false;
        }
        return true;
    }
    
}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users


All the resources listed here are just for testing purpose and they shouldn't be used at any commercial environment without a valid license.
Those are for users who wants to try them before buy. Help the developer to build it better by purchasing them from original authors.