hook_form_alter

decibel.places's picture

Fix for hook_form_alter returns WSOD - remove brackets around new element array members and add $form_state to function

  1. /* Implements hook_form_alter */
  2.  
  3. function back_button_form_alter (&$form, $form_state, $form_id){
  4. if ($form_id == 'video_node_form'){
  5.   $form['back']= array(
  6.         '#type' => 'submit',
  7.         '#value' =>
decibel.places's picture

hook_form_alter returns WSOD when $form_id is checked, $form_id is returned as an array,works on all forms without $form_id test

  1. /* Implements hook_form_alter */
  2.  
  3. function back_button_form_alter (&$form, $form_id){
  4. if ($form_id == 'video_node_form'){
  5.   $form['back']= array(
  6.         ['#type'] => 'submit',
  7.         ['#value'] => t('Make C

preview button code in multi-step user register form via hook_form_alter

  1. // copied below code from the print_r of a node_add form
  2.  
  3. // i want to add a PREVIEW button to the user/register page, next to the SIGNUP (SUBMIT) button
  4.  
  5. // my issue is if I just add this code to

preview button code in multi-step user register form via hook_form_alter

  1. // copied below code from the print_r of a node_add form
  2.  
  3. // i want to add a PREVIEW button to the user/register page, next to the
  4.  
  5. // my issue is if I just add this code to the user/register for

Fix for add permission and hook_form_alter

  1. function custom_love_perm(){
  2.   return array('simplenews_superadmin');
  3. }
  4.  
  5. function custom_love_menu_alter(&$items){
  6.   $items['admin/user/permissions']['access arguments']=array('simplenews_superad

add permission and hook_form_alter

  1. function custom_love_perm(){
  2.   return array('simplenews_superadmin');
  3. }
  4.  
  5. function custom_love_menu_alter($items){
  6.   //print_r($items);
  7. $items['admin/user/permissions'] = Array
  8.         (  
  9.  

Fix for hide preview button

  1. <?php
  2. function mymodule_form_alter($form_id, &$form) {
  3.  
  4.   switch ($form_id) {
  5.  
  6.     case 'mycontenttype_node_form':
  7.         unset($form['preview']);
  8.         break;
  9.   }
  10. }
  11. ?>

Fix for Confirm Submission of Form

  1. <?php
  2.  
  3. function nodetype_submit_form_alter(&$form, $form_state, $form_id) {
  4.         if ( $form_id == 'twittamentary_node_form' ) {
  5.                 $form['form_array'] = array('#value' => '<pre>'. print_r($form,1) .

Confirm Submission of Form

  1. <?php
  2.  
  3. function nodetype_submit_form_alter(&$form, $form_state, $form_id) {
  4.         if ( $form_id == 'twittamentary_node_form' ) {
  5.                 $form['form_array'] = array('#value' => '<pre>'. print_r($form,1) .

Anonymous Track

  1. /**
  2.  * Implementation of hook_init().
  3.  */
  4. function anonymous_track_init(){
  5.         global $user;
  6.        
  7.         // Setup session id
  8.         $sessid = session_id();
  9.        
  10.         // Setup commons variables
  11.         $user_ip = $_SERVER['
Syndicate content