0

I have a module that works on the hook_user (updates) it pushes details to another DB. I only want this module to load on the admin user edit screen where you can assign roles to a user. Currently I have a message that either says because you are role X you are allowed to send data, else sorry you do not have the rights to send data. However these messages display on every page in my drupal 6 website. I was wondering how I can limit this module to just the admin user edit screen, that would help a lot.

0

Check the current user having admin role, if you are using drupal superadmin, then check current logedin user's id equals 1.

<?php
  function custommodule1_user($op, &$edit, &$account, $category = NULL) {
    global $user;
    if($op == 'update') {
      if (in_array("administrator", $user->roles) || $user->uid == 1) {
          // Show message that only for admin.
          // Do whatever you want do for admin.
          drupal_set_message('You are Administrator you are allowed to send data');
      }
      else {
          // Show message for author users.
          drupal_set_message('Sorry you do not have the rights to send data');
      }
    }
  }
?>

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.