I would like to disable the "Promoted to front page" publishing option for all roles except one, is there a way to do this?

Comments

pawpetcare’s picture

I know you can change the default 'promote to front page' behavior for each content type under admin/settings/content-types. Sorry, I don't know if this can be changed on a role-basis.

socketwench’s picture

That helps a bit, but it doesn't prevent users from posting to the front page -- other than denying the ability to post anything to the system other than comments.

chart’s picture

Oke i have a problem my site is in dutch.

go to administrate
then to instellingen I dont now how its in english
then to inhoudtypes I dont now how its in english

you can set the default and not a way to blok. But the standard is changed.

anner’s picture

If you remove the administer nodes capability, they can still create and edit nodes, but they cannot change what this default is set to (that section of the edit page is not displayed).

Jax’s picture

1. You can add "#edit-promote { visibility: hidden; }" to the css of the theme. This will remove the checkbox for everyone.
2. You can apply this patch. This removes the checkbox for everyone but user nr. 1

--- node.module.orig    2006-08-04 16:42:36.000000000 +0200
+++ node.module 2006-08-04 16:41:59.000000000 +0200
@@ -1636,7 +1636,8 @@ function node_form_array($node) {
     $form['options'] = array('#type' => 'fieldset', '#title' => t('Publishing options'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => 25);
     $form['options']['status']   = array('#type' => 'checkbox', '#title' => t('Published'), '#default_value' => $node->status);
     $form['options']['moderate'] = array('#type' => 'checkbox', '#title' => t('In moderation queue'), '#default_value' => $node->moderate);
-    $form['options']['promote']  = array('#type' => 'checkbox', '#title' => t('Promoted to front page'), '#default_value' => $node->promote);
+    if($user->uid == 1)
+      $form['options']['promote']  = array('#type' => 'checkbox', '#title' => t('Promoted to front page'), '#default_value' => $node->promote);
     $form['options']['sticky']   = array('#type' => 'checkbox', '#title' => t('Sticky at top of lists'), '#default_value' => $node->sticky);
     $form['options']['revision'] = array('#type' => 'checkbox', '#title' => t('Create new revision'), '#default_value' => $node->revision);
   }

I do not see another way for the moment.

socketwench’s picture

Gahhh. I can make that change, but I'd rather try to write a small module to do that instead. The problem is I don't have nearly enough drupal knowledge to attempt such a thing.

socketwench’s picture

Is there a way grab a role association and use that in the if statement instead of a uid?

socketwench’s picture

I suppose I could run a query like:

SELECT 1 FROM `users_roles`, `users` WHERE users_roles.uid = users.uid AND users.uid='$user->uid' AND users_roles.rid='$RID'

With $RID being the role allowed to post to the front page, but that's only a slightly less hacked way of doing it. I suppose I could modify the Node module to add "Allow post to front page" as a security permission, but then I'd have to re-implement it in the next version upgrade.

joachim’s picture

Don't alter core.
A custom module with hook_form_alter is what you need rather than hacking core modules.

However, I'm pretty sure there's a custom module that gives you more granular permissions than 'administer nodes' if denying your users that isn't good enough for you.

*EDIT* Oops. Ancient thread. didn't see the dates :/

.carey’s picture

A module that would allow/deny front page publishing based on roles would be great. And maybe even some features on how the front page content will be displayed based on roles (and category/taxonomy/node). ;)

socketwench’s picture

Care to help me write the module? ^^;

.carey’s picture

I didn't respond earlier. I don't know how I missed your post...

On your question:

Care to help me write the module? ^^;

If I knew php I would not only take you up on that offer but I'd be writing a few modules myself. :(

Jax’s picture

The ideal solution would be to add a permission "content_promote" and then assign that permission to a certain role. In your module you would check if that particular user has that permission (with one of the built-in functions).

Now I'm not 100% sure that that checkbox is actually available to modules to remove but it would be a good way to get acquainted with the API and building modules.

With the http://api.drupal.org/api/4.7/function/hook_form_alter hook you might be able to remove the checkbox from the form.

Jax’s picture

It would be something like

<?php
function promote_perm() {
  return array(
'promote content');
}

function
promote_form_alter($form_id, &$form) {
    if(!
user_access('promote content')) {
        unset(
$form['promote']);
    }
}
?>

I'll try to have a closer look tomorrow night (I'm at work for the moment and don't have time tonight). With the module builder module it should be a breeze to complete this.

Jax’s picture

Stick this in a promote.module file:

<?php
function promote_form_alter($form_id, &$form) {
    if(!
user_access('promote content')) {
        unset(
$form['options']['promote']);
    }
}

function
promote_perm() {
  return array(
'promote content');
}

function
promote_help($section) {
  switch (
$section) {
    case
'admin/help#promote':
      return
t('TODO: Create admin help text.');
    case
'admin/modules#description':
      return
t('promote to front page');
  }
}
?>

The roles you give the permission 'promote content' will see the checkbox, others will not.

himagarwal’s picture

Posted at the bottom.

thim’s picture

Hi Jax,

I wouldnt do an unset but rather use an #access parameter, to respect the setting when saving a node

<?php
<?php
function promote_form_alter($form_id, &$form) {
    if(!
user_access('promote content')) {
       
$form['options']['promote']['#access'] = FALSE;
    }
}
function
promote_perm() {
  return array(
'promote content');
}

function
promote_help($section) {
  switch (
$section) {
    case
'admin/help#promote':
      return
t('TODO: Create admin help text.');
    case
'admin/modules#description':
      return
t('promote to front page');
  }
}
?>
mike3k’s picture

I'd like to see a slightly different feature: allow trusted users to post immediately rather than waiting for approval. I normally queue new submissions until I can review and approve them, but for trusted users I'd like to bypass it and allow their posts to appear immediately.

--
Mike Cohen, http://www.mcdevzone.com/

--
Mike Cohen, http://www.mcdevzone.com/

anner’s picture

Make your trusted users a different role and give that role the right to choose whether they publish immediately or not (administer nodes permission).

himagarwal’s picture

This is a very old thread but this is what I require. As I'm new to drupal I don't know how can I use promote.module file created in this thread by user.

<?php
function promote_form_alter($form_id, &$form) {
    if(!
user_access('promote content')) {
        unset(
$form['options']['promote']);
    }
}

function

promote_perm() {
  return array(
'promote content');
}

function

promote_help($section) {
  switch (
$section) {
    case
'admin/help#promote':
      return
t('TODO: Create admin help text.');
    case
'admin/modules#description':
      return
t('promote to front page');
  }
}
?>

Though I copied this code and named it promote.module and transfered it to a new folder "promote" under modules but it just didn't showed up for installation. How can I make this work?

pnlnl’s picture

you must also create a .info file, see the help in the documentation on how to do that

senseBOP’s picture

For those interested, I've create a module for my own personal use, which lets you set each individual option under the Authoring information and Publishing options sections of the node edit page.

At the moment, the module only sets these permissions globally and they apply to all content types.
Once I get approved for a CVS account, I'll contribute my module, and see about adding more features to it, such as choosing which content types the settings apply to, or maybe even a 'per content type permissions' functionality.

Anyways, just wanted to let you guys know that something IS coming, so stay tuned.

P.S. The module was written for Drupal 5.x

himagarwal’s picture

Wow Great! SenseBOP

When do we all expect it to be released. I'm in desperate need of this module. If you want, I'll be the first one to test this out.

senseBOP’s picture

I'm still waiting for the Drupal guys to approve my CVS account. Till then I won't be able to submit the module to the CVS.
For those interested in grabbing it now, just follow the link to get it straight from my site.

Personally, though, I recommend holding on until my CVS application is approved so that everything is done properly and so that versioning, updates and whatnot work.

Download the Publishing Options module
(The link will remain active until I my CVS application is either approved or denied.)

tj2653’s picture

subscribing

stewsnooze’s picture

Did you get the CVS account? Is project now published on drupal.org?

j.somers’s picture

I am also interested in this module, albeit for Drupal 6.x.

Any news about that?

Squirrelly’s picture

Looking forward to this too.

socketwench’s picture

I've come up with a different way to handle who can and can't post to the front page of my site. Instead of relying on "Promoted to Front Page", I use the following modules:

* Advanced Front Page options
* Groups
* OG Content Type Admin (optional)
* VIews

  1. Create a new group for items to post to the front page and capture the nid.
  2. If using OG Content Type Admin, restrict the content types members can post to the group, subscribe members and administrators.
  3. Create a new page view filtering for front page content types, if it's published, and (most importantly) "posted in group". Paste the nid it the appropriate field. Give the page view a unique url, like "front". Don't use "index" as it tends to confuse drupal.
  4. Go to Administer ->Site Configuration -> Advanced Front Page Settings. In "Default Front Page" box, enter the url of your page view. Click submit.
  5. Go back and edit, or create new content and post it to the front page group. You can also use SQL to add nodes to groups en masse.

The neat part about this solution is that it circumvents the rather lackluster "promoted to front page" option, and gives you a lot more control over what ends up on the front page.

The same type of system can be created without Organic Groups using Taxonomy and views. Instead of having the view filter by "posted in group", filter by "terms for n", where 'n' is the post type you want on the front page. The Taxonomy Access Module can be used to secure who gets to use the term that posts to the front page or not.

Squirrelly’s picture

Yes, and you could use CCK and Views to do that too, so gives people a few choices. (I used that to make a 'links' page that authorized people can add a new 'link' content type, and check a box to promote it to the global links page. And it works nicely. Drupal is pretty cool how you can just create something totally new like that, and have it working with almost no work at all.)

But it is annoying to have to go back and change all the old content over for a new front page option. :-)

roblog’s picture

Disable the Edit Node permission for all users except admin - this will stop users from being able to publish to the front page.

Set up a new user group, with Edit Node enabled, and add users to this that you want to be able to publish on front page.

geerlingguy’s picture

The simplest, and dare I say, best solution to this, if you just want to get rid of the field altogether, for everyone (in Drupal 6), is to write a custom module (I called mine custom.module, and added a .info file and put it into a 'custom' folder inside of sites/sitename.com/modules), and paste this function inside (without the ending ?> php line):

<?php
function custom_form_alter(&$form, $form_state, $form_id) {
 
// Remove "Promote to front page."
 
if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {
    unset(
$form['options']['promote']);
  }
}
?>

I stole the node type detection logic from path_form_alter (in the path.module). (Thanks to DaveReid for pointing that out!).

__________________
Work: Midwestern Mac, LLC | Personal: jeffgeerling.com

twooten’s picture

Hi geerlingguy,

Thanks for this code. I made a small modification to it in order to also remove the "sticky" option from the form. The question I have is concerning this part of the code;

$form['type']['#value'] .'_node_form' == $form_id

I'm just trying to understand the purpose of it. It looks like it is just saying "if the name of the form is the same as the form you are on...". Am I missing something?

  if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {
    unset($form['options']['promote']);
    unset($form['options']['sticky']);
    //$v=$form['type']['#value'] .'_node_form';
    //dsm($v);
  }

Thanks,
Tim

SangersDrupalDude’s picture

Go to permissions, uncheck "administer nodes" permission for all roles apart from the one you want and this checkbox will be hidden.

Senior Drupal Web Developer
Wellcome Trust Sanger Institute

joachim’s picture