Skip to main content
knackforge blog knowledge base

Hide "Promoted to front page" and "Sticky at top of lists" options in Drupal

This blog describes how to hide "Promoted to front page" and "Sticky at top of lists" options from node editing page in Drupal. When adding or editing a node, you can see "Publishing options" at bottom of the page which contains 'Published', 'Promoted to front page' and 'Sticky at top of lists' checkbox options. The below image shows you the three options:
 
   Disable promoted to front page and sticky at top of lists options
 
The "Published" option is used to publish the content. The "Promoted to front page" option is used to display content in the front page. The 'Sticky at top of lists' option is used to keep the content sticked to the top of front page. If you don't need to show "Promoted to front page" and "Sticky at top of lists" options, then you can hide those options easily. You can hide these options by altering the form either using either hook_form_alter() or hook_form_form_id_alter().
<?php
/**
 * Implement hook_form_FORM_ID_alter().
 */
function kf_form_article_node_form(&$form, $&form_state) {
  // hide promoted to front page option
  if (isset($form['options']['promote'])) {
    $form['options']['promote']['#access'] = FALSE;
  }

  // hide sticky at top of lists option
  if (isset($form['options']['sticky'])) {
    $form['options']['sticky']['#access'] = FALSE;
  }
}
?>
Now you can't see options "Promoted to front page" and "Sticky at top of lists" while adding or editing the atricle. Similarly, you can hide these options for all node forms using hook_form_base_form_id_alter().
<?php
/**
 * Implement hook_form_BASE_FORM_ID_alter().
 */
function kf_form_node_form_alter(&$form, &$form_state, $form_id) {
  // to hide promoted to front page option
  if (isset($form['options']['promote'])) {
    $form['options']['promote']['#access'] = FALSE;
  }

  // to hide sticky at top of lists option
  if (isset($form['options']['sticky'])) {
    $form['options']['sticky']['#access'] = FALSE;
  }
}
?>
Where "node_form" is the base form id. Using this hook, we can alter all node forms instead of altering each node form separately. Now the options "Promoted to front page" and "Sticky at top of lists" are hidden from all the node forms.