Get the form slug in the hf_form_html filter hook
-
Hi,
I need to filter my forms with
hf_form_html
filter hook, differently for different forms, so I need to get the form slug for this. I found a way how to get the form slug, but maybe exists a proper plugin solution for this. Or not?This is my way:
add_filter( 'hf_form_html', function( $html ) { $doc = new DOMDocument( '1.0', 'UTF-8' ); $doc->loadHTML( $html ); $attr = array(); $form = $doc->getElementsByTagName( 'form' )->item(0); foreach( $form->attributes as $attribName => $attribNodeVal ) { $attr[$attribName] = utf8_decode( $form->getAttribute( $attribName ) ); } if( $attr['data-slug'] == 'my-form-slug' ) { ... } }
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Get the form slug in the hf_form_html filter hook’ is closed to new replies.