Custom Comments Form Action

I’d like to specify a custom default action for the comments form. As I understand it, the Wordpress comment form would be changed by doing something like this:

function custom_comment_form_defaults($defaults) {
    $defaults['action'] = 'https://my-custom-form-action-url.com';
    return $defaults;
}
add_filter('comment_form_defaults', 'custom_comment_form_defaults');

But the Bricks form would be changed via a filter, similar to this:

add_filter( 'bricks/element/form/attributes', function( $attributes, $element ) {
  if ( $element->id === 'commentform' ) {
    $attributes['action'] = 'https://my-custom-form-action-url.com';
  }

  return $attributes;
}, 10, 2 );

Anyone know how to do this correctly?

If you’re using WP comments, it’s the same. If you’re using a Bricks form - it’s fully documented:

Hmm, I don’t think that’s it. Two things:

  1. Looks like the “Actions” are only available for a “Forms” element, not the “Comments” element.
  2. I don’t think this is the same “action”. What I’m talking about changing is in the form where it says <form action="https://domain.com/wp-comments-post.php"

Sorry, you’re right, I had a brain-fart. There are no actions, and generally the bricks comment element seems to be somewhat lacking. A suggested workaround is to disable Bricks comments - and revet to WP comments by adding <?php comments_template() ?> in a code block in your template.

Had a brain-fart of my own. Bricks support replied back saying the comments are handled by Wordpress’ native form… so I tried the code snippet for Wordpress I pasted above, and it worked. Thought I had already tried it, but must have been a slightly different version. So yeah, I pasted the solution with my question…

1 Like