--- /media/disk/workspace/drupal_cvs/contributions/modules/content_profile/modules/content_profile_registration.module_old	2009-01-07 12:02:28.000000000 
+++ /media/disk/workspace/drupal_cvs/contributions/modules/content_profile/modules/content_profile_registration.module	2009-02-20 11:55:12.000000000 
@@ -11,72 +11,89 @@
  */
 function content_profile_registration_form_alter(&$form, &$form_state, $form_id) {
   // Note: We don't add the registration form to the admin create user form.
   if ($form_id == 'user_register' && module_exists('content') && arg(0) != 'admin') {
     require_once drupal_get_path('module', 'node') .'/node.pages.inc';
     $profile_types = content_profile_get_types('names', 'registration_use');
+
     $form += array('#field_info' => array());
 
+
     foreach ($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);
+      $filter = content_profile_get_settings($type, 'registration_filter');
+      if (isset($filter) && $filter != '') {
+      $display = FALSE;
+        foreach (arg() as $arg) {
+          if ($arg == $filter) {
+            $display = TRUE;
+          }
+        }
+      } else {
+        $display = TRUE;
+      }
+      if($display) {
+        // 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);
 
-      $form['#field_info'] += $node_form['#field_info'];
-      foreach ($node_form['#field_info'] as $field_name => $info) {
-        $form[$field_name] = $node_form[$field_name];
-      }
+        $form['#field_info'] += $node_form['#field_info'];
+        foreach ($node_form['#field_info'] as $field_name => $info) {
+          $form[$field_name] = $node_form[$field_name];
+        }
 
-      $keys = array_keys($node_form);
-      foreach ($keys as $key) {
-        if (stristr($key, 'group_')) {
-          $form[$key] = $node_form[$key];
-        }
-      }
+        $keys = array_keys($node_form);
+        foreach ($keys as $key) {
+          if (stristr($key, 'group_')) {
+            $form[$key] = $node_form[$key];
+          }
+        }
 
-      // Set this to the values of one node, as it might be need by some #ahah callbacks
-      $form['#node'] = $node_form['#node'];
-      $form['type'] = $node_form['type'];
+        // Set this to the values of one node, as it might be need by some #ahah callbacks
+        $form['#node'] = $node_form['#node'];
+        $form['type'] = $node_form['type'];
 
-      // Hide fields
-      foreach (content_profile_get_settings($type, 'registration_hide') as $field_name) {
-        $form[$field_name]['#access'] = FALSE;
-      }
-    }
-    if ($profile_types) {
-      $form['#submit'][] = 'content_profile_registration_user_register_submit';
-      $form['#validate'][] = 'content_profile_registration_user_register_validate';
-    }
-  }
+        // Hide fields
+        foreach (content_profile_get_settings($type, 'registration_hide') as $field_name) {
+          $form[$field_name]['#access'] = FALSE;
+        }
+      }
+      if ($profile_types) {
+        $form['#submit'][] = 'content_profile_registration_user_register_submit';
+        $form['#validate'][] = 'content_profile_registration_user_register_validate';
+      }
+    }
+  }
   elseif ($form_id == 'content_profile_admin_settings') {
     $type = $form_state['type'];
     $form['registration'] = array(
       '#type' => 'fieldset',
       '#title' => t('User Registration'),
       '#description' => t('Customize how this content profile shows up on the user registration page.'),
       '#collapsible' => TRUE,
     );
+
     $options = _content_profile_registration_get_field_select($type);
     if (!empty($options)) {
       $form['registration']['registration_use'] = array(
         '#type' => 'checkbox',
         '#title' => t('Use on Registration'),
         '#description' => t('Use this content type on the user registration page'),
         '#default_value' => content_profile_get_settings($type, 'registration_use'),
       );
-      $options = _content_profile_registration_get_field_select($type, FALSE);
-      if (!empty($options)) {
-        $form['registration']['registration_hide'] = array(
+
+      $form['registration']['registration_filter'] = array(
+        '#type' => 'textfield',
+        '#title' => t('Filter Registration'),
+        '#description' => t('This content type will only be displayed if the url argument contains following filterword. Only use 1 argument'),
+        '#default_value' => content_profile_get_settings($type, 'registration_filter'),
+      );
+
+      $form['registration']['registration_hide'] = array(
           '#type' => 'checkboxes',
           '#title' => t('Hide these fields during registration'),
           '#options' => $options,
           '#default_value' => content_profile_get_settings($type, 'registration_hide'),
-        );
-      }
+      );
     }
     else {
       $help = t('There are no fields defined, so registration integration is disabled.');
       $form['registration']['content'] = array('#value' => '<br /><p>'. $help .'</p>');
     }
   }
@@ -103,13 +120,13 @@
  * @param bool $required
  *   If $required is FALSE only not required fields will be returned,
  *   if $required is TRUE only required fields will be returned,
  *   if it's NULL all fields will be returned.
  * @return Array
  *   An array of fields suitable for use in a select field.
-*/
+ */
 function _content_profile_registration_get_field_select($type, $required = NULL) {
   $fields = _content_profile_registration_get_fields($type);
   $return = array();
   foreach ($fields as $fieldname => $info) {
     if (!isset($required) || $required == $info['required']) {
       $return[$fieldname] = $info['widget']['label'];
@@ -167,9 +184,10 @@
 /**
  * Implementation of hook_content_profile_settings().
  */
 function content_profile_registration_content_profile_settings() {
   return array(
     'registration_use' => FALSE,
+    'registration_filter' => FALSE,
     'registration_hide' => array(),
   );
 }
