Adding E-mail to - function THEME_signup_user_form


/ Published in: PHP
Save to your folder(s)

Adding E-mail to - function THEME_signup_user_form


Copy this code and paste it in your HTML
  1. /**
  2.  * Adding Fields to signup HERE!
  3.  */
  4. function THEME_signup_user_form($node) {
  5. global $user;
  6. $form = array();
  7.  
  8. // If this function is providing any extra fields at all, the following
  9. // line is required for form form to work -- DO NOT EDIT OR REMOVE.
  10. $form['signup_form_data']['#tree'] = TRUE;
  11.  
  12. $form['signup_form_data']['Name'] = array(
  13. '#type' => 'textfield',
  14. '#title' => t('Name'),
  15. '#size' => 40, '#maxlength' => 64,
  16. '#required' => TRUE,
  17. );
  18. $form['signup_form_data']['E-Mail'] = array(
  19. '#type' => 'textfield',
  20. '#title' => t('E-Mail'),
  21. '#size' => 40, '#maxlength' => 64,
  22. '#required' => TRUE,
  23. );
  24. $form['signup_form_data']['Phone'] = array(
  25. '#type' => 'textfield',
  26. '#title' => t('Phone'),
  27. '#size' => 40, '#maxlength' => 64,
  28. );
  29.  
  30. // If the user is logged in, fill in their name by default.
  31. if ($user->uid) {
  32. $form['signup_form_data']['Name']['#default_value'] = $user->name;
  33. $form['signup_form_data']['E-Mail']['#default_value'] = $user->mail;
  34. }
  35.  
  36. return $form;
  37. }
  38.  
  39. /**
  40.  * Returns the value to use for the user name for anonymous signups.
  41.  *
  42.  * WARNING: If you implemented your own version of THEME_signup_form_data()
  43.  * that changed or removed the custom 'Name' field and your site
  44.  * allows anonymous signups, you will need to modify this, too.
  45.  *
  46.  * This value is used for the %user_name email token for anonymous users, and
  47.  * also to identify a particular anonymous signup in various places in the UI.
  48.  *
  49.  * @param $form_data
  50.  * Array of custom signup form values for the current signup.
  51.  * @param $email
  52.  * E-mail address of the anonymous user who signed up.
  53.  * @return
  54.  * A string with the proper value for the %user_name email token.
  55.  *
  56.  * @see THEME_signup_user_form()
  57.  */
  58. function THEME_signup_anonymous_username($form_data, $email) {
  59. // In some cases, the best you can do is to use the anonymous user's
  60. // supplied email address, in which case, you should uncomment this:
  61. //return $email;
  62.  
  63. // WARNING: This line is only valid if you left the 'Name' field in
  64. // your site's version of THEME_signup_user_form().
  65. return $form_data['Name'];
  66. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.