Better UI for Drupal user profile page

Created on 28 September 2017, almost 7 years ago
Updated 9 November 2023, 8 months ago

Just quickly making a note of the following that we use to "clean up" the profile form that every client has found confusing, which then means 1000's actual real users that use the system.

Note Biblio to Publications implemented where possible, but considering how the project covers a lot more, maybe a configurable strong that allows users to override defaulting to something meaning for a user of the street using the module for the first time.

function reportal_form_user_profile_form_alter(&$form, $form_state, $form_id) {
  // Hide Biblio fields we don't want.
  if ($form['#user_category'] == 'account' && module_exists('biblio')) {
    $form['#after_build'][] = 'reportal_form_user_profile_biblio_form_after_build';
  }
}

function reportal_form_user_profile_biblio_form_after_build($form, &$form_state) {
  if (isset($form['biblio_fieldset'])) {
    $form['biblio_fieldset']['#title'] = t('Publications');
    foreach (array('biblio_doi', 'openurl', 'biblio_user_style', 'biblio_show_profile', 'biblio_my_pubs_menu') as $key) {
      if (isset($form['biblio_fieldset'][$key])) {
        $form['biblio_fieldset'][$key]['#access'] = FALSE;
      }
    }
    if (isset($form['biblio_fieldset']['biblio_show_profile'])) {
      $form['biblio_fieldset']['biblio_show_profile']= array(
        '#type' => 'value',
        '#value' => 0,
      );
    }
    if (isset($form['biblio_fieldset']['biblio_user_style'])) {
      $form['biblio_fieldset']['biblio_user_style']['#default_value'] = 'system';
      $form['biblio_fieldset']['biblio_user_style']['#value'] = 'system';
    }

    if (isset($form['biblio_fieldset']['biblio_id_change_count'])) {
      $form['biblio_fieldset']['biblio_contributor_id']['#title'] = t('Link your profile with this author from the publications database:');
      $form['biblio_fieldset']['biblio_contributor_id']['#description'] = t('This will link your profile to the selected author from the publications database, then all of the publication KPIs containing this author will be associated with your profile.');
      $count = $form['biblio_fieldset']['biblio_id_change_count']['#default_value'];
      if ($count > 2) {
        $form['biblio_fieldset']['biblio_contributor_id']['#description'] .= ' <strong><em>' . t('You can no longer make changes to your associated author. Please contact your node administrator to unlock this option.') . '</em></strong>';
      }
      elseif ($count == 2) {
        $form['biblio_fieldset']['biblio_contributor_id']['#description'] .= ' <em><strong>' . t('This can be changed once more before this setting is locked.') . '</strong></em>';
      }
      else {
        $form['biblio_fieldset']['biblio_contributor_id']['#description'] .= ' <em>' . t('This can be changed %times more times before this setting is locked.', array('%times' => 3 - $count)) . '</em>';
      }
      if (!empty($form['biblio_fieldset']['biblio_id_change_count']['#disabled'])) {
        $form['biblio_fieldset']['biblio_id_change_count']['#access'] = FALSE;
      }
    }
  }

  return $form;
}

Depending on the user shows

✨ Feature request
Status

Closed: outdated

Version

3.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia Alan D.

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024