I’m just starting out on drupal, so apologies if this is a really silly question. I wrote the following module, but every time I try to access it, going to the url (http://localhost:8888/drupal/doodil_viral_signup) I get an access denied message. I’ve tried rebuilding the permissions and disabling and re-enabling the module, but it doesn’t seem to work.
<?php
// $Id$
/**
* @file
* A module to encourage users to sign up.
* This module allows users to sign up to register for the site, and invite their friends to do the same.
*/
/**
* Implements hook_help().
*/
function doodil_viral_signup_help($path, $arg) {
if ($path == 'admin/help#first') {
return t('This module allows users to sign up to register for the site, and invite their friends to do the same.');
}
}
/**
* Implements hook_menu().
*/
function doodil_viral_signup_menu($may_cache = true) {
$items = array();
if ($may_cache) {
$items[] = array(
'path' => 'doodil_viral_signup',
'title' => t('Doodil Signup'),
'callback' => 'doodil_viral_signup_page',
'access' => TRUE,
'type' => MENU_CALLBACK,
);
}
return $items;
}
function doodil_viral_signup_page() {
return drupal_get_form('doodil_viral_signup_page_form');
}
function doodil_viral_signup_page_form() {
// [input text] First Name
$form['first_name'] = array(
'#type' => 'textfield',
'#title' => t('First Name'),
);
// [input text] Last Name
$form['last_name'] = array(
'#type' => 'textfield',
'#title' => t('Last Name'),
);
// [input text] Email Address
$form['email_address'] = array(
'#type' => 'textfield',
'#title' => t('Email Address'),
);
// [input submit] Sign Me Up
$form['submit'] = array(
'#type' => 'submit',
'#title' => t('Sign Me Up'),
);
return $form;
}
function doodil_viral_signup_page_form_submit($form_id, $form_values) {
$message = 'You have submitted the following information <pre>'.print_r($form_values).'</pre>';
drupal_set_message(t($message));
}
Can anyone tell me how to fix this?
Thanks in advance!
Do everything what
loganfsmythsuggested to you except for thehook_menu(), it should be like this:And remove
doodil_viral_signup_page()function.EDIT
This was just tested on my machine and it’s working perfect. If it wouldn’t work on your machine, then the problem is not in this module.