Got it, @root09!
It’s luckily quite simple. Try these steps:
1. Add a Short Text part to your form. Doesn’t matter where – we’ll eventually hide it with CSS.
2. In your part configuration widget, click the Advanced link.
3. Set your Custom CSS class option to happyforms-part-page-id
. Save your form.
4. Pop this snippet in your theme functions.php
file:
function child_theme_happyforms_part_value( $value, $part, $form ) {
if ( strpos( $part['css_class'], 'happyforms-part-page-id' ) !== false ) {
$value = get_permalink();
}
return $value;
}
add_filter( 'happyforms_the_part_value', 'child_theme_happyforms_part_value', 10, 3 );
5. Refresh the page containing your form, and check the value of this new part we just added. It should contain the current page address.
Let’s nail this down first. If everything worked, we’ll proceed hiding this part with a bit of CSS.
Let us know how you go!