Hey all, been spending time this morning to try and get some profile information into the signup form. Have been going through the module and have almost got everything working. However, I have run into an issue because I don't know PHP very well, and haven't been able to get a selection list to load properly without generating errors.

I followed the textfield example in the form.inc (sp) file before dropping it into my theme's template.php which works great, but I don't know how to do select types properly.

I tried using:
$form['signup_form_data']['grocerylist'] = array(
'#type' => 'select',
'#title' => t('grocerylist'),
);

I am guessing I need to load the #options somehow? Anyway, I am lost.

General timeline of me trying to plow through this: http://drupal.org/node/968540#comment-3696820

Comments

cjeanson’s picture

Emptied out the array so that is just array() and it has removed all of the errors.

Problem is, I notice that none of the profile information is being translated over.

hmm

cjeanson’s picture

Category: support » bug

Indeed I am stumped. Went through the instructions to the letter, and no profile information is being loaded into signup.

Ended up removing everything from template.php so that we are only adding one field, and even that will not load. I can set a default value to ensure that the page is actually doing something, but it will NOT pull any information from the profile.

cjeanson’s picture

Title: template.php customization syntax question » Field Information from Profile not translating to Signup
cjeanson’s picture

I should not that not *all profile information is being ignored - just the fields that I have added.

I am guessing that after we create the relevant code :

==============
$form['signup_form_data']['somefield'] = array(
'#type' => 'textfield',
'#title' => t('somefield),
'#size' => 40, '#maxlength' => 64,
'#required' => TRUE,
);
==============

We need to add something relevant in the user-is-logged-in section, since people will be logged in to sign up. I don't see any documentation to outline how to properly format this information.

The code below:
$form['signup_form_data']['Name']['#default_value'] = $user->name;
Pulls the user's login name. Great, I can also pull their email address using $mail. However, I can't for the life of me find any way to pull the fields that I have just created and populate the signup form.

I suck at this. :)

cjeanson’s picture

Been reading through various sources on Drupal.org, and have been reading a lot of conflicting information on how to pull information from a user's profile into a theme.

Some people are saying to use $account, others say use $profile, but nothing really works when messing around in the "logged-in" section of template.php

However, using $user, I can pull any of a handful of information that is stored there. Unfortunately, this doesn't have the information I want.

Digging around in my database, the information I want is stored in profile_values.

The question is, how can I pull the relevant information from that table into this signup display (from my template.php theme file)?

cjeanson’s picture

Ended up getting an answer from another Drupal user, informing me of the joy of the following:

profile_load_profile($user);

inserted into the above phptemplate_signup_user_form() made all of the difference.

My function now sits as:
==========================================
function phptemplate_signup_user_form() {
global $user;
profile_load_profile($user);
$form = array();

// If this function is providing any extra fields at all, the following
// line is required for form form to work -- DO NOT EDIT OR REMOVE.
$form['signup_form_data']['#tree'] = TRUE;

$form['signup_form_data']['Name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#size' => 40, '#maxlength' => 64,
'#required' => TRUE,
);
$form['signup_form_data']['profile_charname'] = array(
'#type' => 'textfield',
'#title' => t('Character Name'),
'#size' => 40, '#maxlength' => 64,
'#default_value' => $user->profile_charname,

);

// If the user is logged in, fill in their name by default.
if ($user->uid) {
$form['signup_form_data']['Name']['#default_value'] = $user->name;

}

return $form;
}
=====================================
I would recommend updating the relevant documentation to make this easier. Now this module can see some heavy lifting on our site!

kclarkson’s picture

Is there a different way to add this functionality without messing with the code?

kclarkson’s picture

Is this code still the only way to add this functionality

coltrane’s picture

I need this functionality. ezra-g recommends it be a separate module because signup.module is already quite feature-rich. I'll report back here with what I get uploaded.

coltrane’s picture

A sandbox of Signup Profile field integration is now available http://drupal.org/sandbox/coltrane/1135966 http://drupal.org/project/signup_profile

kclarkson’s picture

@Coltrane

Link not working

coltrane’s picture

kclarkson’s picture

@coltrane,

Thanks for the module!!!!

After enabling your module I can now see the additional profile fields in the signup block.

I would like to know, is it possible to add the functionality to auto populate the information from the profile?

Basically we would like to have users just click the signup button vs. having to enter their information in again. Is that possible without having to alter the PHP code?

Thanks again,

kclarkson’s picture

I guess PHP isn't that hard if you just stay at it :)

My solution was to add cjeanson's code to the signup_pane_example.module file.

The file is located in the signup -> modules -> signup-pane-example.

I copied cjeasons code starting on line 77 and erased the stuff that was there. like so:

global $user;
profile_load_profile($user);
$form = array();

$form['signup_form_data']['first_name'] = array(
'#type' => 'textfield',
'#title' => t('First Name'),
'#size' => 40, '#maxlength' => 64,
'#required' => TRUE,
);

// If the user is logged in, fill in their name by default,
// except in the special case where the admin user is adding other users.
if ($user->uid && $signup_type != 'admin') {
$form['signup_form_data']['first_name']['#default_value'] = $user->profile_first_name;
}

return $form;

}

Because I added additional fields within the profile module the KEY piece is adding the correct field name. You can see the actual field name under the profile settings.