• Resolved Ramesh (thecodeisclear)

    (@thecodeisclear)


    I am trying to write a plugin to add a new field to the comments form. I have searched (both in codex & in the support form) and I now know how to do it. I have used hook for “comment_form_default_fields” and added my new field (it is a checkbox). This works fine if no user is logged in. However, if the user is logged on, the form shows with only the comments textarea. Can you tell me what I am doing wrong here (or is it supposed to work this way)?

    PS: I am testing on WordPress 3.4 (with no plugins) running TwentyEleven theme.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    You probably just need to change the class of your field so the CSS displays your field regardless of the user’s login state. For instance, try using the same class as the textarea. As you have seen, the class of the other fields get disappeared by CSS when the user is logged in.

    Thread Starter Ramesh (thecodeisclear)

    (@thecodeisclear)

    Thanks bcworkz. Though the issue was not related to the CSS, I was able to find the solution. I am adding it below so that others may benefit.
    Earlier, I was using the fields array variable and appending my new variable to the element ‘url’ (under the fields array). The entire variable “fields” is not output when an user is already logged in.

    However, the element ‘comment_field’ under the defaults array will always be displayed.

    $default[ 'comment_field' ] .= 'code for my new field here'

    outputted the new field at all times. Marking this as resolved.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘New custom field in comments form does not appear for signed in users’ is closed to new replies.