Theme Button Classes on WPForms Submit Buttons
Adds your theme's button classes to every WPForms submit button, so forms match the other buttons on your site without extra CSS.
Opens WPIDE on
Code
$wpide_wpf_button_classes = 'wp-element-button';
add_filter( 'wpforms_frontend_form_data', function ( $form_data ) use ( $wpide_wpf_button_classes ) {
if ( ! isset( $form_data['settings'] ) || ! is_array( $form_data['settings'] ) ) {
return $form_data;
}
$current = isset( $form_data['settings']['submit_class'] ) ? (string) $form_data['settings']['submit_class'] : '';
$form_data['settings']['submit_class'] = trim( $current . ' ' . $wpide_wpf_button_classes );
return $form_data;
} );
Notes
Set the classes your theme uses, such as wp-element-button for block themes or btn btn-primary for Bootstrap themes.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.