I need to create two separate registration forms for over- vs under-18 users with completely different sets of fields. Is there a way to activate multiple different Content Profile content types for anonymous users depending on the URL they're on? I'm happy to code it myself, just need a pointer in the right direction.

Comments

greenbeans’s picture

OK, I can't even get both content types to show on a single registration form at once. Am I doing something wrong?

EDIT: Never mind. Got it working. Here's the relevant code. It basically just reverses everything done in content_profile_registration_form_alter() ... there's probably a better way to do this:



  if ($form_id == 'user_register' && module_exists('content') && arg(0) != 'admin') {
    require_once drupal_get_path('module', 'node') .'/node.pages.inc';
    $all_profile_types = content_profile_get_types('names', 'registration_use');
    $used_profile_types = $all_profile_types;
    $unused_profile_types = array();
    $form += array('#field_info' => array());
		//check our URL for which profiles should be enabled.
		if($_GET['mode'] == 'child' && isset($all_profile_types['adult_profile'])) {
			$unused_profile_types['adult_profile'] = $all_profile_types['adult_profile'];
		}
		else if($_GET['mode'] != 'child' && isset($all_profile_types['child_profile'])) {
			$unused_profile_types['child_profile'] = $all_profile_types['child_profile'];
		}

    foreach ($unused_profile_types as $type => $typename) {
      // Initialize new node:
      $node = array('uid' => 0, 'name' => '', 'type' => $type);
      // Get the node form
      $node_form = drupal_retrieve_form($type .'_node_form', $form_state, $node);
      drupal_prepare_form($type .'_node_form', $node_form, $form_state);

      foreach ($node_form['#field_info'] as $field_name => $info) {
      	unset($form['#field_info'][$field_name]);
        unset($form[$field_name]);
      }

      $keys = array_keys($node_form);
      foreach ($keys as $key) {
        if (stristr($key, 'group_')) {
          unset($form[$key]);
        }
      }
    }
    
    if (!count($used_profile_types)) {
			if (($key = array_search('content_profile_registration_user_register_submit', $form['#submit'])) !== False) {
					unset($form['#submit'][$key]);
			}
			if (($key = array_search('content_profile_registration_user_register_validate', $form['#validate'])) !== False) {
					unset($form['#validate'][$key]);
			}
    }
  }	

manoloka’s picture

Rosamunda’s picture

Could something like this be implemented into content profile module itself?

Equ’s picture

Subscribe

momper’s picture

subscribe

keyo’s picture

subscribe.
Auto assign role module is worth looking at since it can provide multiple registration forms for different roles on separate urls/tabs/menus.

http://drupal.org/project/autoassignrole

kenorb’s picture

cyrusvhadsupper’s picture

subscribing

doublejosh’s picture

Would love Content Profile and Auto Assign Role to place nice.

All registration pages show all profile field from all content profile types.

mmilano’s picture

subscribe: this would be a highly valuable feature.

mmilano’s picture

#1 didn't end up working for me with my custom content types, so I added a few lines to content_profile_register.module. I posted about it here: http://drupal.org/node/870644

ayalsule’s picture

subscribing

kenorb’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Drupal 6 is no longer officially supported. If you think this issue is still relevant for 8.x, feel free to re-open.