How to force user to add links?

apasaja - December 12, 2008 - 04:40
Project:Related links
Version:5.x-2.2-beta
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

Hello,

Is there any way to force user to add links (Manual links) when submitting?

Thanks in advance

#1

dereine - December 12, 2008 - 10:02

write a custom hook_form_alter which looks like this

<?php

/**
* Implementation of hook_form_alter().
*/
function hook_form_alter($form_id, &$form) {
  if (
user_access('add related links') && isset($form['type']) &&
    (
$form['type']['#value'] .'_node_form' == $form_id)) {
      if (!
in_array($node->type, variable_get('relatedlinks_node_types', _relatedlinks_node_get_types(TRUE)))) {
        return;
      }
     
// force the user
     
$form['relatedlinks_fieldset']['relatedlinks']['#required'] = TRUE;
     
$form['relatedlinks_fieldset']['keywords']['#required'] = TRUE;
  }
}
?>

 
 

Drupal is a registered trademark of Dries Buytaert.