Read whole thread to find out all the details.

I couldn't save profile type, because of form validation error "Invalid option 'authenticated' [...]". Checked the form and indeed, there were two places, where "Check user roles that should have this profile after registering" could be set. Only in one place, there was only "administrator" option, and it was the cause of validation error.

I checked in various places, and:

In on line 142 there is

    $form['regpath']['settings']['roles'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Assign roles during registration'),
      '#description' => t('Please select any roles that you would like to automatically assign to users registering via this registration path.'),
      '#options' => $roles,
      '#default_value' => $default_roles,

While in on line 60

if (!empty($role_name) && !array_key_exists($rid, $form['account']['roles']) && isset($user_roles[$rid])) {
          $form['account']['roles'][$rid] = array(
            '#type' => 'checkbox',
            '#title' => check_plain($user_roles[$rid]),
            '#default_value' => TRUE,
            '#disabled' => !user_access('administer users'),

So there was kind of a clash between these two. I commented out the first one and now it works as expected.


Ok, I digged a bit deeper into the issue. Looks like I've ported regpath module by myself. And problem lies in adding same functionality to the form from within profile and regpath module.

Line 56 of

  $form['roles'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Roles'),
    '#description' => t('Check user roles that should have this profile.'),
    '#options' => $user_roles,
    '#default_value' => !empty($profile_type->roles) ? $profile_type->roles : array_keys($user_roles)

Here we have role checkboxes attached in function creating form. And later in hook_form_alter from within regpath module they were attached again, in different place.

So not really a bug, but a clash between modules, of which one I ported by myself, so no one to blame here except me. I will edit title accordingly.