The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$archive_pages - Line: 2 - File: printthread.php(287) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/printthread.php(287) : eval()'d code 2 errorHandler->error
/printthread.php 287 eval
/printthread.php 117 printthread_multipage



UserSpice
how to hide link - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: Miscellaneous (https://userspice.com/forums/forumdisplay.php?fid=28)
+--- Forum: Documentation (https://userspice.com/forums/forumdisplay.php?fid=30)
+--- Thread: how to hide link (/showthread.php?tid=183)

Pages: 1 2


how to hide link - ejaw - 07-14-2016

hi how can i hide link from side menu for a group of users
thank's


how to hide link - mudmin - 07-14-2016

It sounds like you are wanting to use a negative logic. Here's how you need to think of this...

When you are on the admin dashboard, you see that there is a place at the top that says how many permission levels and you can manage them. When you click on manage them and click on administrator, you are taken to a page that shows you the id of that permission level. You're going to need that permission level id for your hiding feature.

Normally, we SHOW links if someone is a permission level. In the regular navigation.php we have this setup to show the admin dashboard only to admins.

Code:
<?php if (checkMenu(2,$user->data()->id)){  //Links for permission level 2 (default admin) ?>
//whatever you want to show
Code:
<?php } // is user an admin ?>

In your case, you want to figure out which permission level you want to NOT show, let's say it's an id of 3.

At the top of your navigation page in the custom php section, you need to write a query to check the db to see if your user is part of that particular permission group.

Code:
$id = $user->data()->id;
Code:
$permLev = 3; //the permission level you don't want to see the menu item.

Code:
$query = $db->query("SELECT * FROM user_permission_matches  WHERE user_id = $id AND permission_id = $permLev");
Code:
$amIbanned = $query->count(); //If this count comes back as 1, that user is part of the group. If zero, then not.

So, now for your menu...
Code:
<?php if $amIbanned = 0 { ?>
menu link here
Code:
<?php } ?>

If that's not exactly it, it's really close. There might be a different way to do it, but I don't think the checkmenu helper function can be turned around in reverse.





how to hide link - ejaw - 07-15-2016

Got It, Thank you.


how to hide link - picassoo - 10-05-2016

ejaw you find the solution ?


how to hide link - ejaw - 11-02-2016

I added this function to us_helpers

/*************************************/
function checkLinkAccess($id,$page_id) {
$db = DB::getInstance();
global $user;
//Grant access if master user
$access = 0;

if ($access == 0){
$query = $db->query("SELECT user_permission_matches.user_id FROM user_permission_matches
LEFT JOIN permission_page_matches
ON permission_page_matches.permission_id = user_permission_matches.permission_id
WHERE permission_page_matches.page_id='$page_id'
AND user_permission_matches.user_id='$id'");
$results = $query->count();
if($results>0){
return true;
}else{
return false;
}
}
}
/**********************/
then i use :
<?php
if(checkLinkAccess($user->data()->id,'83')) {
?>
[*]
link1

<?php
}
?>

83 is the page ID


how to hide link - dan - 11-07-2016

Ideally you want to make these changes in usersc/includes/custom_functions.php

We update the us_helpers.php file pretty often with bug fixes and new features. Copying that function over there won't affect its performance.


how to hide link - sire - 03-14-2017

is this great but how can i show some links if the user is not longed in


thanks
sire


how to hide link - mudmin - 03-15-2017

Sure...so if you want to show a link (or anything) only if the user is logged in, wrap the whole thing in this.

Code:
if($user->isLoggedIn()){
Code:
//your code here
Code:
}  // close if statement.

You can also do
Code:
if(!$user->isLoggedIn()){
Code:
//your code here
Code:
}

If you only want to show code to users who are not logged in.


how to hide link - sire - 03-19-2017

ok i am trying to have the nav bar to show different links to the different permission groups
like admin, user, and gest


how to hide link - JUG - 03-19-2017

sire, check the original navigation.php file. There you have <php> code for showing content only to certain groups (like showing admin dashboard only to admins)

[Image: Navigation.PNG?dl=0]

Code:
<pre>
Code:
<!-- Here goes navigation for every visitor (logged, not logged, admins, not admins... -->

<!--------------------------------------------------------------------------------------->
<?php if($user->isLoggedIn()){?>
   <!-- Here goes navigation only for logged visitors ----------------------------------->

   <!------------------------------------------------------------------------------------>
  
   <?php if (checkMenu(2,$user->data()->id)){?>
      <!-- Here goes navigation only for admins (visitors with permission level 2) ------>

      <!--------------------------------------------------------------------------------->
   <?php }?>

   <?php if (checkMenu(1,$user->data()->id)){?>
      <!-- Here goes navigation only for users (visitors with permission level 1) ------->

      <!--------------------------------------------------------------------------------->
   <?php }?>
<?php }else{?>
   <!-- Here goes navigation only for users who are not logged in ----------------------->

   <!------------------------------------------------------------------------------------>
<?php }?>
</pre>


This code should be somewhat familiar with navigation.php. Try to add yourself <ul> and <li> classes and check if you can get the navigation you want. You should only change the navigation.php file in usersc/includes folder NOT in users/includes!

Also check bootstrap navbar to see how you can easily make navigation with buttons, links, dropdown menus and combine these two codes together.