Anyone know if there's a way to allow users without "administer nodes" checked to actually be able to change the "Authored on" date of their stories? Or a way to limit "administer nodes" to just a user's own (self created) nodes?
I have a sitie where I need to allow users to post stories from/to either the past or future— very rarely on the same date as when they're logged in and create the story. I can see how this is done when "access control->administer nodes" is checked, but then that also seems to allow a user to modify any other user's stories, which I definitely don't want.
I've searched around and found the following possibly related posts, which all seem to say the answer might be no, but I'm really hoping there's a solution out there since Drupal does everything else so well:
Any help much appreciated!
Thanks,
KV
Comments
small module
You probably should just do this via a small module using hook_form_alter.
See the forms API for more info: http://api.drupal.org/api/4.7/file/developer/topics/forms_api.html
As well as this mini module, for example: http://drupal.org/node/70906
The code below is adapted pretty much straight from the node.module (Drupal 4.7). This is the sort of code you'd put in your hook_form_alter implementation to add the date field for non-admin users to the node form:
note- I haven't actually tested this code; Caveat Emptor.
---
Work: BioRAFT
similar problem
Hi,
I have a similar problem: I want to allow visitors (with a certain role) to add pages and indicate under which menu item this page is to be shown without giving them access to the entire menu system. Would you have a solution to that too??
Peter
Well, perhaps
Well, perhaps - first you should try out the code above and see if it actually works! You'll have to look at the menu module itself- it may be that without giving the "administer menus" permission, users can never add a menu item.
---
Work: BioRAFT
Thanks! Any plugins/modules?
Thanx very much for the fast & detailed feedback; I'm not at all familiar with the forms API (or even where this hook code would go), so I've got some reading to do.
But in case it's frankly over my head, also wondering if there's not a plugin or module that does something similar w/ less engineering (not being a hard-core coder myself)? I just ran across the Actions module and wonder if I added and exposed a custom vocab of mm/dd/yyyy to a story, perhaps I could have the Actions and/or Workflow automatically (behind the scenes to the user) set a story's publish date to that custom-vocab date... so the user would just enter a value in my new "To be published on date:" field for that story and the module would take it from there. I'm not very familiar w/ either Actions or Workflow yet so will check into that as well.
Ya know i'm sorta surprised that Drupal doesn't have an out-of-box feature like this because it seems like such a common feature to mainstream blog apps. But BIG kudos to the Drupal community for making such a powerful tool; i'm constantly surprised by just what IS possible (and often so fast)— rather amazing. In fact, this is actually the 1st real non-trivial problem for me w/ this site, and I've added quite a few behind-the-scenes features ('course as Murphy would have it, it's a must-have feature requirement for my site).
Thanks again,
KV
--note: just found incompatability error between my VotingAPI and Actions module; will research
small module homework
OK, in order to
pretend Iknow what I'm doing before adding hook_form stuff, I thought I'd read up first— started at http://drupal.org/node/17914 and went through a few tutorial steps there. That's some heavy reading! Actually, it's not too bad and pretty well explained (to contributors: thank you). But I can see it's going to take me (non-programmer) some significant time to make sure I know enough to feel comfortable implementing the above hook_form_alter implementation w/out fear of breaking my site and/or giving non-admins too much inadvertant access.Some newbie clarification questions on the above code:
BTW, I have a feeling this level of PHP/coding is a bit over my head, so if anyone has an existing small module or other code available, please feel free to post. :)
Thanks
KV
see:
see: http://drupal.org/node/70906
This includes the code for an entire small module that modifies the node form via hook_form_alter.
---
Work: BioRAFT
This is how I do it!
This is the code allowing people with no 'node administer' right to access 'Authored on' (and possible 'Authored by') field:
Note that the hook_submit() is used to update the $note->uid and $node->created variable, as the node_submit() does not automatically do this! Hope this help!
Almost there...
Huan, thanks much... this almost works!
Actually it seems to work fine for Story nodes, but I'm using CCK nodes (custom node) and when I change your code above to reference the content, the 1st function (in my case, I change it to "content_form_alter") does display the Authoring information field for entering the date, BUT the 2nd function (in my case, when I change it to "content_submit") throws an error:
Fatal error: Cannot redeclare content_submit() (previously declared in /home/modules/...) ... on line 293
And, as you suggested, when i remove the 2nd function my CCK content.module does display the Authoring information field for non-admins, but does not actually save/update the node with the edited info.
I looked up the line in content.module in my site and it does already have a content_submit() function defined, so I'm thinking about just taking your 2nd function above and dropping it into my content.module. But not sure what that might mess up so wanted to ask if there might be another way to do it-- like is there a way to modify the existing content_submit() function from my own module and not edit the content.module (or should I just do the latter)? I searched the handbook for something like submit_alter but didn't see it available.
Thanks again,
KV
well meanwhile i got brave
well meanwhile i got brave and tried it... added your following code to content.module as the 1st function inside my content.module's content_submit(&$node) function:
Seems to work!
I'm still a bit concerned that i may have created unwanted side-effects, so please feel free to reply if you think there's a better way (see my previous post here).
BTW, I'm still quite surprised it seems not many other Drupal devs have a need to allow their non-admin users to enter/edit creation dates for their own nodes as i thought back-dating of nodes was a pretty popular feature of many blog, etc sites? Maybe not, but here's hoping to someone implementing it for Drupal v5 or perhaps a universal module for those of us that do (i'd take it on myself if I knew more about PHP/Drupal coding).
I also hope they would add
I also hope they would add the ability to allow admins to define which groups can specify the "author by" and "author on" info w/o having to grant them administer nodes privileges.
I've created a small module to do this
See Edit Date Authored.
// David Lesieur // Whisky Echo Bravo // Web applications development // Montreal, Canada //
NICE!!! :-) Well, I actually
NICE!!! :-)
Well, I actually haven't tried your mod yet 'cause I have things working at the moment with my hack... er, patch... but I was looking for a solution for so long that I just wanted to say your contrib is MUCH appreciated-- if not by myself, then I'm sure by other newbies as IMO this seemed like a small but very important function for Drupal to be missing.
Renamed
The module has been renamed to Edit Authoring Information.
// David Lesieur // Whisky Echo Bravo // Web applications development // Montreal, Canada //
How can I help bring this to 5.x?
I'm interested in this module because I think it would let me have a pseudo-administrator (a user with the role of Facilitator) CREATE NODES of content type "group" (used by the Organic Groups module) AND SWITCH THE AUTHOR to the group's manager (another user with the role of Contributor Manager).
But, I'm running Drupal 5.1. I know there are some pages on upgrading modules, but I'm not sure how I can help...
Convoluted solution to change OG Manager:
http://drupal.org/node/81318
Contrib modules version 5.x status:
http://drupal.org/node/82257
Converting 4.7.x modules to 5.x:
http://drupal.org/node/64279
"Nothing easy is ever simple." -- Plucky Duck
Exactly what I'm looking for
I'm a bit surprised that there's not an easy solution for 5.x. Am I missing something?
---------------------------------------
Gus Austin
PepperAlley Productions
---------------------------------------
Gus Austin
I'm looking forward for this
I'm looking forward for this as well. How about version 5.1? how to port?
The module doesn't work with
The module doesn't work with Drupal 5.x. I've filled an issue: http://drupal.org/node/187336.
--
by FiNeX
FiNeX.org
Siti Web Vicenza
Ok, after some test I've
Ok, after some test I've found that the module works if the taxonomy access control is not enabled: http://drupal.org/node/187336
--
by FiNeX
FiNeX.org
Siti Web Vicenza
Invaluable module!
I am not sure why something as basic as specifying the published date, or having a separate notion of "published" and "created" date, is not part of the core functionality of Drupal, but with this module I can get this behaviour without granting administrative permissions to users.
Thanks so much and keep up the great work!
is there something similar,
is there something similar, but for work flow states?