/**
 * Form validation function for guestbook_form_entry_form.
 */
function guestbook_form_entry_form_validate($form, &$form_state) {
  // Check whether name of anonymous user is an registered user's name.
  if (isset($form_state['values']['anonname'])) {
    if ($existing = user_load(array('name' => $form_state['values']['anonname']))) {
      form_set_error('anonname', t('%name is a registered user name. Please enter a different name.', array('%name' => $form_state['values']['anonname'])));
    }
  }
}

Why do we have to do this?
It causes a problem for anonymous users - they have to waste time picking available name.

Comments

parasolx’s picture

Through logical, its correct not to waste time by checking all username currently registered in system. But it may cause a conflict in identification once a duplication name for anon appear same with registered user.

So i think it should and must have this counter check. However, this make even a registered user didn't pass to submit any comment since system detect the name already in database.

So, i manage to modified the operator to bypass this check when user is login.

At line of

if (isset($form_state['values']['anonname'])) {

change it to:

  if (isset($form_state['values']['anonname']) && !(user_is_logged_in())) {
aexchecker’s picture

Better use !empty(), see patch for http://drupal.org/node/1467828#comment-5686556

parasolx’s picture

Argh.. i don't think by using !empty much more appropriate.

Thanks.

quotesbro’s picture

Version: 6.x-2.0 » 6.x-2.x-dev
aexchecker’s picture

Status: Active » Closed (fixed)