WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Im trying unhook the comment form found in the functions.php of the deafault buddypress theme so I can change it a bit. I placed this piece of code into my child theme functions.php but it didn't change anything. What did I do wrong?

remove_filter( 'comment_form_defaults', 'bp_dtheme_comment_form', 10 );
if ( !function_exists( 'my_dtheme_comment_form' ) ) :
function my_dtheme_comment_form( $default_labels ) {
global $user_identity;

$commenter = wp_get_current_commenter();
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
$fields =  array(
    'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name', 'buddypress' ) . ( $req ? '<span class="required"> *</span>' : '' ) . '</label> ' .
                '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
    'email'  => '<p class="comment-form-email"><label for="email">' . __( 'Email', 'buddypress' ) . ( $req ? '<span class="required"> *</span>' : '' ) . '</label> ' .
                '<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
    'url'    => '<p class="comment-form-url"><label for="url">' . __( 'Website', 'buddypress' ) . '</label>' .
                '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>',

$new_labels = array(
    'comment_field'  => '<p class="form-textarea"><textarea name="comment" id="comment" cols="60" rows="10" aria-required="true"></textarea></p>',
    'fields'         => apply_filters( 'comment_form_default_fields', $fields ),
    'logged_in_as'   => '',
    'must_log_in'    => '<p class="alert">' . sprintf( __( 'You must be <a href="%1$s">logged in</a> to post a comment.', 'buddypress' ), wp_login_url( get_permalink() ) ) . '</p>',
    'title_reply'    => __( '', 'buddypress' )

return apply_filters( 'my_dtheme_comment_form', array_merge( $default_labels, $new_labels ) );
add_filter( 'comment_form_defaults', 'my_dtheme_comment_form', 10 );

To test that nothing changed I removed the label text for 'title_reply'

share|improve this question
Kindly provide the context in which the form is hooked in the original functions.php, the original filter has most probably not been added at that stage yet, wrap it in an 'init', 999 action, or later. – soulseekah Mar 25 '12 at 3:28
Hmmm I don't know what you mean by context. All I did was copy the function and paste it to my functions.php and then I changed the function name on the add_filter to my. – Pollux Khafra Mar 25 '12 at 5:11
The remove_filter function has to be used with the exact same arguments that the filter was added with. You said you have a child theme, so the parent theme contains and add_filter somewhere, you have to remove it with the exact same arguments (priority, numargs) to actually remove it. Find add_filter( 'comment_form_defaults', 'bp_dtheme_comment_form' ... ) and make sure it's got the same exact arguments that you're using to remove. Hope that makes sense. – soulseekah Mar 25 '12 at 5:37
I had already done that. You can see it at the top of the code above. That's why I'm confused it's not working. – Pollux Khafra Mar 25 '12 at 6:52
...again, the remove_filter function has to be used with the SAME exact arguments that the filter was added with. Meaning that if the filter was added like this: add_filter( 'tag', 'function', 12, 3 ); it should be removed with remove_filter( 'tag', 'function', 12, 3 ); - the exact same arguments have to be used. It will not be removed otherwise. So are you sure that your remove function matches the add function in the parent theme? – soulseekah Mar 25 '12 at 9:13
up vote 0 down vote accepted

Solved - I didn't realize wordpress overwrites the functions in the default theme if I place them in my child theme functions.php. So all I had to do was paste them into my functions.php and edit how I want them.

share|improve this answer


add_action( 'init', 'remove_bp_comment_filter' );
function remove_bp_comment_filter() {
    remove_filter( 'comment_form_defaults', 'bp_dtheme_comment_form', 10 );
    remove_action( 'comment_form_top', 'bp_dtheme_before_comment_form' );
    remove_action( 'comment_form', 'bp_dtheme_after_comment_form' );
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.