0

I have website created in Drupal LMS "Openscholar". Its a academy site and there are various,they have there on vsite where they can add content as per there role.When user logged in ,there is a link to "Delete Vsite" available on his/her profile,

enter image description here

Therefore,my issue is that he can delete his account without concerning Admin.I tried to hide it using "Display:none" in CSS but it will hide Delete link for admin too. Thus, i want to know how to resolve such issue ?

0

You can solve it by using a condition in your code. If current user is admin then show that Delete Link else hide it.

global $user;
if(in_array('administrator', $user->roles){
  your code to show link
}
4
  • why you use user_load function if you define global user already – Adi Dec 3 '15 at 8:12
  • ya, its right @Adi – Abin Dec 3 '15 at 8:14
  • how to add css property "Display:none" within such code ? – Rajender Rajan Dec 3 '15 at 8:21
  • 1
    if you are trying code then no need of adding "Display:none;". If you want add Display:none then give it as inline or as in your stylesheet. – Abin Dec 3 '15 at 8:29
0
 $global $user
    //Get admin_id from database and add condition
    if ($admin_id == $user->uid){
         add your code here 
         }

Hope this idea of code is helpful for you

4
  • can i do the same for a user other than Admin ? Moreover, can i add css to in this custom code ? One more thing where to add this code i.e in which file ? – Rajender Rajan Dec 3 '15 at 8:08
  • 1
    yes you can use for everyone user ,create custom module then place or add this code in page.tpl.php (its not good way) – Adi Dec 3 '15 at 8:11
  • how to use css within this code ? – Rajender Rajan Dec 3 '15 at 8:13
  • If we have more than 1 admin, $admin_id will become error or become more complicated. Use abin's answer – user49951 Dec 3 '15 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.