Customized comment_form(), closing divs, and user login status
-
Hi WordPressers,
I’m modifying my theme to include a comment form within a <table>. User login status is causing closing divs to appear and disappear, breaking the form.
I suspect I’m hooking into the wrong place or over writing something, but can’t figure out where. I’d appreciate any ideas or suggestions.
In more detail, I’ve added the following to functions.php to add the table rows and cells:
[code moderated - please follow the forum guidelines for posting code]
This seems to work fine. I've added the following to open and close the table:
function mw_comment_before() { echo '<table id="CommentTable"><tbody>'; } add_filter( 'comment_form_before_fields', 'mw_comment_before' ); function mw_comment_after() { echo '</td></tr></tbody></table></form></div></div>'; } add_filter( 'comment_form', 'mw_comment_after' );
Note the two terminal div tags in mw_comment_after. These tags are necessary when the user is logged out, but cause the form to break if the user is logged in.
So, I could use a conditional statement to add/remove the div tags depending on login status. But this seems to be a hacked solution. I rather find a more elegant solution, and understand why the tags are needed when logged out.
I suspect that I'm hooking into the wrong place, or over writing something important, but can't figure out where. As a point of interest, I'm using Otto's Simple Connect plugins for FB ad Twitter. These produce a module that also hooks into the comment form and adds a div #alternate_login_methods. I wonder if my functions are replacing something from the plugin?
I'm totally lost on this one! I'd appreciate any ideas, suggestions, or even just a systematic way to debug this and work out where the additional divs are coming from!
Thank you for your help.
- The topic ‘Customized comment_form(), closing divs, and user login status’ is closed to new replies.