| 1 |
<?php
|
| 2 |
// $Id: signup_form.inc,v 1.4 2009/01/07 00:55:00 dww Exp $
|
| 3 |
|
| 4 |
|
| 5 |
/**
|
| 6 |
* @file
|
| 7 |
* Site-specific code related to the form when users signup for a node.
|
| 8 |
*/
|
| 9 |
|
| 10 |
/**
|
| 11 |
* Return the site-specific custom fields for the signup user form.
|
| 12 |
*
|
| 13 |
* To customize this for your site, copy this entire function into
|
| 14 |
* your theme's template.php file, rename the function to
|
| 15 |
* phptemplate_signup_user_form(), and modify to taste. Feel free to
|
| 16 |
* alter any elements in this section, remove them, or add any others.
|
| 17 |
*
|
| 18 |
* WARNING: If your site allows anonymous signups and you alter the
|
| 19 |
* 'Name' field in this function, you will probably have to implement a
|
| 20 |
* version of theme_signup_anonymous_username() for your site.
|
| 21 |
*
|
| 22 |
* In order for the form to be rendered properly and for the custom
|
| 23 |
* fields to be fully translatable when printed in other parts of the
|
| 24 |
* Signup module (displayed in signup lists, emails, etc), the name of
|
| 25 |
* the form element must be $form['signup_form_data']['NameOfDataField'],
|
| 26 |
* where NameOfDataField is replaced with the actual name of the data
|
| 27 |
* field. For translation to work, the displayed name of the field
|
| 28 |
* (the '#title' property) be the same as the name of the data field,
|
| 29 |
* but wrapped in t(). See below for examples.
|
| 30 |
*
|
| 31 |
* Fieldsets are not currently supported in this form. Any
|
| 32 |
* '#default_value' will be filled in by default when the form is
|
| 33 |
* presented to the user. Any field marked '#required' must be filled
|
| 34 |
* in before the user can sign up.
|
| 35 |
*
|
| 36 |
* If you do not want any additional fields, the function can simply
|
| 37 |
* return an empty array: "return array();"
|
| 38 |
*
|
| 39 |
* @param $node
|
| 40 |
* The fully loaded node object where this signup form is appearing.
|
| 41 |
*
|
| 42 |
* @return
|
| 43 |
* Array defining the form to present to the user to signup for a node.
|
| 44 |
*
|
| 45 |
* @see theme_signup_anonymous_username()
|
| 46 |
*/
|
| 47 |
function theme_signup_user_form($node) {
|
| 48 |
global $user;
|
| 49 |
$form = array();
|
| 50 |
|
| 51 |
// If this function is providing any extra fields at all, the following
|
| 52 |
// line is required for form form to work -- DO NOT EDIT OR REMOVE.
|
| 53 |
$form['signup_form_data']['#tree'] = TRUE;
|
| 54 |
|
| 55 |
$form['signup_form_data']['Name'] = array(
|
| 56 |
'#type' => 'textfield',
|
| 57 |
'#title' => t('Name'),
|
| 58 |
'#size' => 40, '#maxlength' => 64,
|
| 59 |
'#required' => TRUE,
|
| 60 |
);
|
| 61 |
$form['signup_form_data']['Phone'] = array(
|
| 62 |
'#type' => 'textfield',
|
| 63 |
'#title' => t('Phone'),
|
| 64 |
'#size' => 40, '#maxlength' => 64,
|
| 65 |
);
|
| 66 |
|
| 67 |
// If the user is logged in, fill in their name by default.
|
| 68 |
if ($user->uid) {
|
| 69 |
$form['signup_form_data']['Name']['#default_value'] = $user->name;
|
| 70 |
}
|
| 71 |
|
| 72 |
return $form;
|
| 73 |
}
|
| 74 |
|
| 75 |
/**
|
| 76 |
* Returns the value to use for the user name for anonymous signups.
|
| 77 |
*
|
| 78 |
* WARNING: If you implemented your own version of theme_signup_form_data()
|
| 79 |
* that changed or removed the custom 'Name' field and your site
|
| 80 |
* allows anonymous signups, you will need to modify this, too.
|
| 81 |
*
|
| 82 |
* This value is used for the %user_name email token for anonymous users, and
|
| 83 |
* also to identify a particular anonymous signup in various places in the UI.
|
| 84 |
*
|
| 85 |
* @param $form_data
|
| 86 |
* Array of custom signup form values for the current signup.
|
| 87 |
* @param $email
|
| 88 |
* E-mail address of the anonymous user who signed up.
|
| 89 |
* @return
|
| 90 |
* A string with the proper value for the %user_name email token.
|
| 91 |
*
|
| 92 |
* @see theme_signup_user_form()
|
| 93 |
*/
|
| 94 |
function theme_signup_anonymous_username($form_data, $email) {
|
| 95 |
// In some cases, the best you can do is to use the anonymous user's
|
| 96 |
// supplied email address, in which case, you should uncomment this:
|
| 97 |
//return $email;
|
| 98 |
|
| 99 |
// WARNING: This line is only valid if you left the 'Name' field in
|
| 100 |
// your site's version of theme_signup_user_form().
|
| 101 |
return $form_data['Name'];
|
| 102 |
}
|
| 103 |
|