First of all, you need CCK module installed to install Content Profile, and after download and place in your modules directory, you need Content Profile and Content Profile User Registration.

By default after install content profile, it auto creates a content type named Profile.

With that, you should create new fields for your profile, as name, address, and others convenient to your application. You can also ignore or delete this, and create a new content type to become your 'profile' type.
After creating your fields, you can now integrate that directly to the user register form, by clicking in the Content profile tab in the correspondent type edit page, but in case this link does not exist,
certify to check the option "Use this content type as a content profile for users".

Now in the Profile page of your content type, you have now a dozen of custom settings, and you may see the group User Registration, and you need to check Use on Registration, and you can also hide fields from your type in the registration form. Remember, if you don`t want the body field, you can delete its
label from the type edit page, and with that, it will become inaccessible.

Your user register page has now the fields from your content type, plus the default register fields like email, username, and password.

This should be enough in most cases, but you may need to place your node type fields before the default register fields, and, trying to clarify the things a bit, the content profile merges the user register form with your node form (custom profile type). So to change the order of them in the user register page, you need to go in your type profile settings, and find the Weight field, and set it to be lighter than the user register form.

Now, going again to the user register page, we have now our node type fields placed before the default register fields.

But, again, this may not be enough, and you may need to custom the order of the fields, by mixing the node type fields with the user register fields, for example, Name, Username, Email, Telephone, Country, and Password. In this case, there is no configuration page and we will have to code a bit.
First, you need a custom module, if you don't know how, check this up (http://drupal.org/node/231276).
An important point to highlight, is that this module need to be executed after the module content_profile_registration. If you open your database, and go to the table system, you will see that you module should have the weight = 0, and the module content_profile_registration has its weight = 1, so, just update your module`s weight to 2. Follows the sql query:
update system set weight = 2 where name = 'mymodule';
After that, we need to implement a hook_form_alter, create a #content_profile_weights key in the form array, with a position for each field, and its correspondent weight and applies a content profile pre render to change the fields weights. Follows a small piece of code that does that.
<?php
/**
* Implementation of hook_form_alter().
*/
function mymodule_form_alter(&$form, &$form_state, $form_id) {
//We need to manipulate the user_register form
if ($form_id === 'user_register') {
//Define a very light number
$counter = -10000;
//Create an array that has the exac order of your fields
$order_fields = array(
'field_name',
'name',
'mail',
'field_telephone',
'field_country',
'pass',
);
//Explicit the order of each field from the array
foreach ($order_fields as $field) {
$form['#content_profile_weights'][$field] = $counter++;
}
$form['#pre_render'] = !$form['#pre_render'] ? array() : $form['#pre_render'];
//Apply a content profile render specifically to change the fields weights
array_unshift($form['#pre_render'], 'content_profile_registration_alter_weights');
//Fix data in form state
array_unshift($form['#submit'], '_content_profile_fix_formstate_values');
}
}
/**
* For some reason, the submitted data is not been sent correctly, and I just get them back in this function
*/
function _content_profile_fix_formstate_values(&$form, &$form_state){
//This function is in submit, so the data has already been validated
$pass = $form['#post']['pass']['pass1'];
$form_state['values'] = $form['#post'];
$form_state['values']['pass'] = $pass;
}
?>In the $order_fields array, it has the common machine name fields in the user register, 'name', 'mail' and 'pass'. And the other field names are all from my profile node type and they must be
also the machine names, and you can check this in the Manage fields from your profile content type.

And Voilà! We have now a customized user register form.







written by Capi Etheriel Tue, 08/09/2011 - 14:08
Quote Reply
Sofri muito pra chegar no mesmo resultado, por ignorância minha. Meu principal problema, depois de resolver os pesos dos módulos, é que os hook_form_alter rodam antes dos hook_form_FORM_ID_alter (que eu estava usando).
Agora, uma vez que o hook_form_alter estiver rodando depois do content_profile_registration_form_alter, o que você precisa fazer é adicionar outra função no #pre_render. É simples: $form['#pre_render'][] = 'nova-funcao';
E na nova função, que recebe &$elements como argumento, você só precisa mudar os weights do jeito que achar melhor. Veja meu código no github https://github.com/barraponto/nossasp_features/blob/master/nossasp_manta... e um screenshot do sucesso http://ompldr.org/vOXRxZA
written by lnunes Tue, 08/09/2011 - 14:39
Quote Reply
Fala Capi...
Inicialmente eu usei um pre render também, alterando os pesos individualmente dos campos (exatamente como seu código no github), porém, sempre que usava o pre render, por algum vudu, todos os dados do node_form eram perdidos, portanto só o usuário era criado, e o content profile não, lembrando que estou no form do user_register, e não no node_form.
Com isso, tive que apelar, e usar o próprio pre render do content profile, para mudar o peso dos campos... Isso acabou resolvendo.
Valeu!
written by Ani Wed, 08/17/2011 - 09:26
Quote Reply
I tried your above code, but for some reason my content profile is not being created. Can you tell me why?
written by lnunes Wed, 08/17/2011 - 12:19
Quote Reply
Hi, be sure to update your module weight, and also, in the submit function _content_profile_fix_formstate_values, check if the form_state variable comes with the form data.
written by arun chandran Wed, 11/02/2011 - 11:25
Quote Reply
When i use this code file upload not working at the time of user register.
My function is
<div class="codeblock"><code>function personal_profile_form_alter(&$form, &$form_state, $form_id) {<br /> <br /> //We need to manipulate the user_register form<br /> if ($form_id == 'user_register') {<br /> <br /> //Define a very light number<br /> $counter = -10000;<br /> <br /> //Create an array that has the exac order of your fields<br /> $order_fields = array(<br /> 'account',<br /> 'field_typeaf_profil',<br /> 'field_personal_navn',<br /> /*'field_email_adresse',*/<br /> 'userinfo',<br /> 'field_worktitel',<br /> 'field_arbejdsplads',<br /> /*'name',<br /> 'mail',<br /> 'pass-pass1',<br /> 'pass-pass2',<br /> 'group_fieldset',<br /> 'group_select',<br /> 'field_personlig_hjemmeside',<br /> 'field_arbejdsplads_hjemmeside',<br /> 'field_interest_areas',<br /> 'field_personlig_twitter_ko',<br /> 'field_personal_fb',<br /> 'field_personal_linkedin',<br /> 'field_google_profile',<br /> 'password',*/<br /> 'user_roles',<br /> 'logo_upload_register',<br /> 'picture_upload_register',<br /> 'profile_company',<br /> 'profile_contactperson',<br /> 'profile_address',<br /> 'profile_zip',<br /> 'profile_city',<br /> 'profile_mail',<br /> 'profile_phone',<br /> 'profile_web',<br /> 'profile_ean',<br /> 'profile_twitter',<br /> 'profile_rss',<br /> );<br /> <br /> //Explicit the order of each field from the array<br /> foreach ($order_fields as $field) {<br /> $form['#content_profile_weights'][$field] = $counter++;<br /> }<br /> <br /> $form['#pre_render'] = !$form['#pre_render'] ? array() : $form['#pre_render'];<br /> <br /> //Apply a content profile render specifically to change the fields weights<br /> array_unshift($form['#pre_render'], 'content_profile_registration_alter_weights');<br /> <br /> //Fix data in form state<br /> array_unshift($form['#submit'], '_content_profile_fix_formstate_values');<br /> <br /> }<br />}<br /><br />/**<br />* For some reason, the submitted data is not been sent correctly, and I just get them back in this function<br />*/<br />function _content_profile_fix_formstate_values(&$form, &$form_state){<br /> <br /> //This function is in submit, so the data has already been validated<br /> $pass = $form['#post']['pass']['pass1'];<br /> $form_state['values'] = $form['#post'];<br /> $form_state['values']['pass'] = $pass;<br /> <br />} </code></div>
written by MoodyMadleine Fri, 11/04/2011 - 12:24
Quote Reply
Hi everybody. I 've just managed to register and thought I will create a little offtopic here. If the category is wrong, moderation, please move the topic to correct forum category. That is my first post on that board. I would be happy if whoever could help me with this issue. The one who can resolve my issue gets served with bottle of beer :)
_______________
<a href=http://wyszukiwarka-mp3.eu/mp3/880aea6cfe6b0fa3301df36ca54aebb9/Fiedas%2... mp3</a>
written by Eduslysweedly Mon, 11/07/2011 - 09:53
Quote Reply
comment_body[und][0][value]