By raghukr on
I am writing a module for custom content type. And for the content type I am writing, revisions does not make sense. Is there a way to disable revisions (not allow users to create revisions) for my content type either programmatically (in my module code) or user permissions?
Thanks in advance.
Comments
As usual, no help from
As usual, no help from drupal community. I have figured it myself.
I added the below code in hook_validate()
a little late, but better than never ...
adding this in template.php in your theme removes revisions for good
don't forget to flush theme caches so you can see the results
Setting in Drupal to turn off Revisions?
@madaerodog...
Is there no place in Drupal to turn off revisions? If not, I find that hard to believe. Also, if not, where would I post a request for that feature?
[Update: never mind... I found it.] ;-)
Btw, is there a way for the owner of a post to delete it? As in... I would like to delete this one instead of leaving a useless post out there to be searched (and potentially wasting the time of others by reading it).
It's never too late to have a happy childhood. ;-)
Found it?
Please share.
~ Mike Usry
SEO Firm
You're so right...
@musry7... You're so right. I should have posted the answer. Sorry for that omission.
Go to admin/content/types and edit the content for which you wish to turn off revisions. In "Workflow settings", uncheck "Create new revision". Simple, but hard to find. (I had to search a while to find it again myself.)
It's never too late to have a happy childhood. ;-)
Cannot find "workflow settings" (Drupal 7)
Hi. Thank you helping. Is this in reference to Drupal 6? I cannot find "workflow settings" in Drupal 7.
Also, does this affect node revisioning at the node level? What if I want to stop the uploaded files from being revisioned with names like file.pdf, then file_0.pdf, then file_1.pdf?
Thank you!
Kevin
RE: Cannot find "workflow settings" (Drupal 7)
Ditto - it doesn't appear to be a setting in Drupal 7. This "forward progress on new versions of Drupal" without also some breakdown or organization of documentation on D7 vs D6 vs D8 vs DX and expecting the community to pick up the pieces is a big dissapointment.
Hard to find in D7 as well...
For D7... go to admin/structure/types/manage/[content-type]
Near the bottom, click "Publishing options"...
The bottom checkbox is "Create new revision"... uncheck to disable revisioning by content type.
It's never too late to have a happy childhood. ;-)
No, that's incorrect. It sets
No, that's incorrect. It sets the default action to create a new revision when you save changes to a node.
node_form_alter
Hello,
hope this help, you can disable it with a form alter hook.
Remove them completely
To remove the revisions from showing in the admin, just changed a bit the function given above to:
Via
I was also surprised that this wasn't easier. Still, that's why we write modules :-)
Here is a similar brutal approach using hook form alter.
This was really just a proof of concept (it works) - In an ideal world we want to check more about the form type - make sure that it's a node edit etc.
I think I might throw together a module that does this all in a better way and allows some per-node-type configuration.
Drupal 8
For Drupal 8, go to /admin/structure/types/manage/[content-type-name]
and the checkbox is under the publishing options.
Not working for me
The only checked option under default options of Publishing is "Published". "Create new revision" is un-checked and still doesn't get rid off Revision Information checkbox (only checkbox but no textarea though) on node edit ! Cleared Cache, closed and again re-opened session still no luck. The only role is 'authenticated user' in permissions and Authenticated User has only Add New Node for that specific content type set. Nothing else. I really, don't want to handle everything in code. Any other suggestion please ?
By default, the revisions
By default, the revisions option is only shown to users with permission to create/edit revisions. If you do not have this permission selected and the user is still seeing the revision checkbox, it means you have a module or theme that is altering Drupal core functionality. You'll need to figure out which module/theme that is and disable it.
Contact me to contract me for D7 -> D10/11 migrations.
It's plain Out Of Box D8 Setup
Hello Jaypan,
Thanks for the reply. Well, my setup is pure Default out of box Drupal 8 Setup (8.7.7 to be specific). No contributed module or theme installed, so we're covered on that note as well. Only permission I changed is "Add xyz Type Content" and "Edit Own xyz Type Content" to the 'Authenticated User'. In fact I even removed all Default permissions provided by default and kept only these two permission to authenticated user and still no luck. On top of that 'Authenticated User' does not hold 'Administer content' permission so that's also covered. And I still see Revision related box at the bottom of Node Edit.
I am lost now, and started regretting D8 for sure. Was so pleased with D7 but D8 is really making me regret for its odd, unruly behavior.
Any help would be really appreciated. Thanks
Are you logged in as the
Are you logged in as the first user you get with the site? That user bypasses any permissions checks, so the permissions you select will not matter.
Contact me to contract me for D7 -> D10/11 migrations.
Logged in as a non-admin
Well, No, not as a first user. I am logged in as authenticated user and not administrator, user having uid = 3. So this user must not see the revision form ideally.
Did you solved this? I have
Did you solved this? I have same problem. Revisions disabled, no permission for revisions for user role, yet users see checkbox to create a new revision when editing content. (Drupal 8.9.3)
CSS
I have the same problem. In my case, the following css works:
.vertical-tabs {display: none;
}