*************** *** 78,83 **** function content_profile_page_access($type, $account) { if ($node = content_profile_load($type, $account->uid)) { return node_access('update', $node); } --- 78,94 ---- function content_profile_page_access($type, $account) { + $valid_role = FALSE; + $valid_roles = variable_get('content_profile_roles_'. $type, array()); + foreach($valid_roles as $role_id) { + if(isset($account->roles[$role_id])) { + $valid_role = TRUE; + break; + } + } + if(!$valid_role) { + return FALSE; + } if ($node = content_profile_load($type, $account->uid)) { return node_access('update', $node); } *************** *** 256,261 **** '#title' => t('Use this content type as a content profile for users'), '#default_value' => variable_get('content_profile_use_'. $form['#node_type']->type, FALSE), ); } elseif (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id && is_content_profile($form['#node'])) { // Customize the redirect target and buttons of our own node forms. --- 267,278 ---- '#title' => t('Use this content type as a content profile for users'), '#default_value' => variable_get('content_profile_use_'. $form['#node_type']->type, FALSE), ); + $form['content_profile']['content_profile_roles'] = array( + '#type' => 'checkboxes', + '#title' => t('For what roles should this profile be used'), + '#options' => _content_profile_valid_roles(), + '#default_value' => variable_get('content_profile_roles_'. $form['#node_type']->type, array()), + ); } elseif (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id && is_content_profile($form['#node'])) { // Customize the redirect target and buttons of our own node forms.