Enabling multiple content profile types for user registration only gives the node->title and node->body fields for the last (in order) content profile type.

To Reproduce:

1) Install content profile and it's user registration component
2) Enable two content types to be used for content profile
3) Enable these content profiles to be available for registration
4) On the registration form, you will only get one body and title field.

The attached patch fixes this problem, by suffixing the body and title fields with the node type. Later on submit, it fills the body and title fields with the correct node type values and let's node save handle the rest.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nohup’s picture

Patch file attached.

nohup’s picture

Status: Active » Needs review
BlackCatWeb’s picture

I have the same problem - needing both content profiles showing at registration. However, even with your patch, only one still shows. Any clues?

notasheep’s picture

Following

stefan81’s picture

subscribe

eelkeboezeman’s picture

subscribe

eelkeboezeman’s picture

patch works great

nohup’s picture

@BlackCatWeb: Did you apply it to the content_profile_registration.module ?

Skybax’s picture

Hello Nohup

Your patch did not work in my case.
I had first multiple node types activated for profile registration. But then unchecked it all, uninstalled and
deleted the profile content module.

Then reinstalled it, but still the same. Can you tell me in which table I can find this check box for registration then I can maybe alter it in the database.

I used your patch for content_profile_registration.module , but nothing changed. (I did it manually).
Still only the body field and the title field that appears for registration.
But one inside you can create such a content type (or edit it) and you can see the other fields.
So only in registration it does not show up.

I did the patch manually:

So the first part becomes:

// Add in the new form elements into $form.
$form += array('#field_info' => array());
$form['#field_info'] += $node_form['#field_info'];

//change the body and title
$body_field='body_field_'.$type;
$form_add['body_field']['body_'.$type]=$form_add['body_field']['body'];
unset($form_add['body_field']['body']);
$form_add[$body_field]=$form_add['body_field'];
$form_add['title_'.$type]=$form_add['title'];
unset($form_add['body_field'],$form_add['title']);

//fix the format field to be after the body field
if(isset($form_add[$body_field]['format'])) {
$form_add[$body_field]['_format']=$form_add[$body_field]['format'];
unset($form_add[$body_field]['format']);
$form_add[$body_field]['format']=$form_add[$body_field]['_format'];
unset($form_add[$body_field]['_format']);
}
$form += $form_add;

Second part:

function content_profile_registration_user_register_validate($form, &$form_state) {
require_once drupal_get_path('module', 'node') .'/node.pages.inc';

foreach ($form['#content_profile_registration_use_types'] as $type => $typename) {
// Set the body and title for the current type
if(isset($form_state['values']['body_'.$type])){
$form_state['values']['body']=$form_state['values']['body_'.$type];
}
if(isset($form_state['values']['title_'.$type])){
$form_state['values']['title']=$form_state['values']['title_'.$type];
}
$node = (object)$form_state['values'];
$node->type = $type;
node_object_prepare($node);

If there is any fault in my manually patching can you let me know?

Thanks.

nohup’s picture

Try the following

  1. Download the development release of the content_profile module
  2. Enable Content Profile and Content Profile User Registration modules
  3. Create at least 2 content profile content types, for testing, name the title and body fields so that they can be identified on the user registration page with their content types.
  4. On the Content Profile tab of each select "Use on Registration"
  5. In a different browser open the /user/register, you will see the title and body from only one of the content types
  6. Download the patch
  7. Go the content_profile/modules directory
  8. Apply the patch with patch -p0 content_profile_registration.module < /path/to/content-profile-registration-939146-1.patch
  9. Refresh the /user/register page
  10. You will now be able to see the title and body fields form both the modules
operations’s picture

Hi nohup,
I have two roles (parent, teacher).. I defined 2 content types as user profiles for that; using the Content Profile module.

I used Auto Assign Role module v6.x-2.0-beta1 , cause v6.x-1.2 (the official release) displays a warning on the content profile settings page of a content type (foreach warning). Then, I used the built-in content type and changed the name to Parent, then added another one for teacher. So, I had 2 content types as profiles each one of them has its own cck fields to be displayed in the appropriate user role page. I applied the Assign from path option which is in the AAR module settings page.

For ex:- register/parent => some fields ....
register/teacher => another fields .... to be determined using permissions of each role.

My problem I have now, is that no edit link is displayed for the registered user once he/she login!! Though I configured everything correctly, and I didn't have this error before unless I added the auto assign role from path and multiple profiles. .

Update: That was because of not assigning the roles access to content and content profiles. I was in a hurry :)

operations’s picture

Also, I have two tabs in the admin user (uid:1) , when editing a user from the users list page..

First tab: Teacher Profile, second tab: Parent Profile ! I guess it shouldn't be like this as its annoying once the user has been built for a specific role (1 role value must be there).

Please let me know if I'm heading wrong ?

fralenuvol’s picture

The above patch fixes for me also another issue:
I have 2 content types enabled on user registration page, one with body field, the other one with body field hidden.
When user registers, the hidden body field, instead of being empty, gets saved with the same value of the visible body field of the other content type.
The patch of comment #1 solves the issue.
Thanks nohup.

mogop’s picture

subscribe

YK85’s picture

subscribing

sketman’s picture

Hi, doesnt solve this the Auto Assign Role module?
http://drupal.org/project/autoassignrole
I works with Content Profile module...

pmathur01’s picture

Hi,

I have multiple registrations on my website. In the first case I have a user(Role1) that uses Profile1 and the second case user (Role2) uses Profile 2. Is there some way that I can make the user choose the Role and then based on the role the Profile is shown to the user. Example in My Account Profile 1 is shown to Role1 users and Profile 2 is shown to Role 2 users.

I used Auto asign role module but I am not able to show how the registration forms are to be shown.. Can someone help with how to how proceed.

Thanks,
Prerna

operations’s picture

Hi Prerna,
Have you checked the auto assign role settings at this page:

/admin/user/autoassignrole

third fieldset: Allow User to Choose

You can choose which roles can be determined and more options there.

Is this what you need ?

pmathur01’s picture

Hi,
Thanks, I did use that and it is assigning the role but it is not populating the content profiles based on that role. How do I choose as to what profile to display on the Account page based on that role. Right now it is displaying both the profiles on My Account page.

Thanks,
Prerna

operations’s picture

Thats strange, I did the same and it worked for me. However, please be sure that you enable "assign from path" fieldset in the same admin page settings for auto assign role.

Here is what I did in details:

  • Enabled both Content Profile & AAR modules
  • Created two content profiles (teacher, parent) and added CCK fields and permissions for each profile
  • Enabled "assign from path" and added a user register node to determine which role is needed. Before this stage you have to create a starting page that has two links or photos in order to let the users choose the appropriate role before entering their information.
  • In this fieldset you will find other fieldsets forming all the roles in the system. I enabled the two roles (teacher, parent) then assigned a new path for each registration page like: user/register/parent

I think in your case you don't need the "allow user to choose" to be enabled. "Allow user to choose" lets the users choose from a set of roles during the registration page.

Please let me know if you are still stuck in it so I can help you further, as I spent a lot of time before figuring it out.

Enjoy :)

pmathur01’s picture

Thanks for your help. I did not get one thing when u say that I need to "create a starting page that has two links or photos in order to let the users choose the appropriate role before entering their information." I am providing the login/register on my front page. Do I create another block with "Role2 Register Here" with a url directing them to some page. If so which page?

operations’s picture

Sorry for late reply I was a bit busy on some projects. I meant that you can create a page (node of type page) with two links to the two paths you've already defined in the AAR configurations (Assign from path). This will enable you to determine the role of the user before displaying the required fields.

Please let me know if you still don't get my point.

--Mohannad