Hey, everyone.
I'm trying to figure out how I can programatically affect access to the 'default' create content page for a custom node type, in my case 'listing'. In other words, restrict access to 'node/add/listing' based on the return value of a function I create.
Here's some background: My client wants people to pay for placing a property listing for a certain amount of time. Each listing will run for that amount of time, then get deactivated. I'm developing a way to add a 'listing credit' onto the customer's account based on a reply from PayPal. But that's neither here nor there.
I would be able to do this if I were just defining a MENU_CALLBACK in hook_menu(), but can't seem to sort out how I would do it for the 'default' form. Any suggestions are welcome.
Comments
You can try this
You can try this hook_access() http://api.drupal.org/api/function/hook_access/.
If you created the new node type 'listing' by CCK, you can add some code to restrict access of this node type in function node_access in node.module
for example
if ($node == 'listing' and $op == 'create')
return FALSE;
then nobody can access 'node/add/listing'
It's not a CCK-generated node type
I would rather not modify the node module, is there something I can do in my custom module?
Also, I didn't create the custom node type using CCK, I did it manually with a new .module file, then used CCK to add fields to the 'listing' node.