Hello,

On my site guestbook, I would like to have registered users filling in their names, just as anonymous users. I've been trying to alter the code myself but I can't seem to get it right. I figure this is the code that would need to change:

  if ($user->uid == 0 && $user->uid != 0) {
    // fields for anonymous poster
    $form['anonname'] = array(
      '#type' => 'textfield', '#title' => t('Name'),
      '#size' => 32, '#maxlength' => 64, '#required' => TRUE,
    );
    $anonymous_fields = (array) variable_get('guestbook_anonymous_fields', array('email', 'website'));
    if (in_array('email', $anonymous_fields)) {
      $form['anonemail'] = array(
        '#type' => 'textfield', '#title' => t('E-mail'),
        '#size' => 32, '#maxlength' => 128,
      );
    }
    if (in_array('website', $anonymous_fields)) {
      $form['anonwebsite'] = array(
        '#type' => 'textfield', '#title' => t('Homepage'),
        '#size' => 32, '#maxlength' => 128,
      );
    }
  }
  if (_guestbook_access('post', $uid) == 'allowed') {
    if ($user->uid == 0) {
      // anonymous user
      $result = db_query("INSERT INTO {guestbook} (anonname, anonemail, anonwebsite, author, recipient, message, created)
        VALUES('%s', '%s', '%s', %d, %d, '%s', %d)", $form_state['values']['anonname'], $form_state['values']['anonemail'], $form_state['values']['anonwebsite'], 0, $uid, $message, time());
    }
    else {
      // registered user
      $result = db_query("INSERT INTO {guestbook} (author, recipient, message, created)
        VALUES(%d, %d, '%s', %d)", $user->uid, $uid, $message, time());
    }
  }
  // author
  if ($entry['author'] == 0) {
    $author = "<b>". check_plain($entry['anonname']) ."</b>";
  }
  else {
    $author = "<b>". theme('guestbook_user_picture', $entry['author']) ."</b>";
  }

  $output .= '<div class="author">'. $author .'</div>';

Could anyone point me in the right direction for changing this code? I'm far from an expert on MySQL/PHP ;)

Thanks!

Comments

sun’s picture

Status: Active » Closed (won't fix)

Sorry, unfortunately this request is way too specific. You might want to try to get further support at http://drupal.org/support.

If you were able to solve this issue on your own in the meantime, you might want to add the involved steps to this closed issue, so other users searching for a similar solution might find it.