HI all,
I'm using the profile module to add a bunch of fields (mainly contact details) on each user.

I've also created a custom nodetype module, and on the 'add' form of the nodetype, i want to read those fields.

E.g. sample code from mymodule_form(&$node)

        global $user;
        drupal_set_message($user->name; $user->profile_firstname); // debug
	$form['billing']['bill_firstname'] = array(
		'#type'				=> 'textfield',
		'#title'			=> t('First Name'),
		'#default_value'	=> $user->profile_firstname,
		'#prefix'			=> "<div class='OrderBlock'>",
		'#suffix'			=> "</div>",
	);	
	$form['billing']['bill_lastname'] = array(
		'#type'				=> 'textfield',
		'#title'			=> t('Last Name'),
		'#default_value'	=> $user->profile_lastname,
		'#prefix'			=> "<div class='OrderBlock'>",
		'#suffix'			=> "</div>",
	);	

but none of the profile fields are coming through (i.e. drupal_set_message only prints the users user name and not firstname. Am I doing something wrong? How can I access the extra fields?

Comments

nevets’s picture

You need to call profile_load() to have access to the profile fields. In this case you would call it as profile_load($user);

high1memo’s picture

ah thanks. that sounds like the kinda thing I was missing! i shall give it a shot...

high1memo’s picture

I only just got round to trying it.! Just for the record if anyone else is reading this thread, the function is actually profile_load_profile... and then it works like a charm

radiofranky2009’s picture

Hi,
I think i'm a bit closer to what I want to achieve after reading your post.
This is what I'm trying to achieve.

Able retrieve field info from the current post node and pass to author_pane.

somehow I need to able to read the current node array with all the fields and diplay them in author_pane

your feedback is appreciated