0

As author of my content type I can choose any user (current user, even anonymous).

Nodes will created programmatically, so:

$node->uid = $current_user->uid;

However I want to allow access to node/add/custom_type (node form) only for Administrator or even block for everyone.

I am no totally sure that Drupal checks permissions before node_save(), so that's why I am asking.

1 Answer 1

2

If what you are asking is...

How can I allow nodes of a certain type to be created programmatically by everyone, but, at the same time, disallow everyone but the Administrator from creating them from the UI?

...the quickest way might be for you to use Rules to create a redirect away from node/add/custom_type for everyone but the Administrator.

However, if you are already creating custom module code, you could also do this pretty simply in hoot_init(), eg, something along the lines of:

global $user;
if ($_GET['q']=='node/add/custom_type') {
   if ($user->uid != 1) { // or whatever logic you want to use to determine the Administrator
     drupal_goto('somewhere else');
   }
}

In either case, you'd have to set up permissions to allow any user to create these types of nodes.

1
  • Ok thanks, I probably just use permissions to allow access to node/add/type to only Admin. About node_save(), I checked this and permissions are checked in layer higher. In database layer you can control everything
    – Codium
    Commented Feb 15, 2013 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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