• Hi,

    What I need is to add one field before submit button in all over my wordpress network sites` comment forms. I have user comment_form function with its some filters and there are was no any luck.
    Please advise how can I do this.

    Regards,
    Turkel.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter turkel

    (@turkel)

    Anyone, please give me some tips. I only need WP-MS plugin which will add my field to all sites` comment forms.

    Moderator bcworkz

    (@bcworkz)

    The themes used would need to use the comment_form() function for the related filters to work, have you verified this is the case?

    The filters are setup for adding fields above the comment textarea only, but you can actually use the ‘comment_form_field_comment’ filter to add a separate field after the textarea, just do something like this:

    function add_example_field($textarea){
       return $textarea.'Label: <input id="example" name="example" type="text">';
    }
    add_filter( 'comment_form_field_comment', 'add_example_field' );

    Then hook the ‘pre_comment_on_post’ action to capture the field value and do something with it.

    Thread Starter turkel

    (@turkel)

    I have used that function as plugin for standalone wp and it wont worked. there were no any changes on comment fields.
    I have tried function below:

    function add_field () {
    echo '<input name="extra_field" title="somthing_extra />"';
    }
    add_action("comment_form","add_field");

    By use of function above (add_field) I am able to show extra field after submit button, but actually I need extra field to be displayed before the submit button.

    Thread Starter turkel

    (@turkel)

    My theme`s comments.php rewrites what is generate by plugin. I am not sure how to overwrite it :S What I need is plugin which will overwrite comment fields for all themes in my wp network.

    Moderator bcworkz

    (@bcworkz)

    The code I suggested works for any theme using the comment_form() function, I did test it before posting. If it does not work, you either have an error in how you implemented the code snippet or your theme does not use the comment form function.

    In the latter case, how you add the field would depend on the code the theme is using. There may not be any hook you can use for a plugin solution, you may need to alter the theme template directly so that it does call comment_form(), or directly hack the theme’s form generation code.

    To avoid losing such changes to themes, you need to create a child theme for each theme that was so customized.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Global Comment modification for Multisite WP’ is closed to new replies.