wpcf7_form_name_attr

The contact-form-7 wpcf7 form name attr hook.

Published Date - July 22, 2023

Description

$name_attr = apply_filters( 'wpcf7_form_name_attr',
			preg_replace( '/[^A-Za-z0-9:._-]/', '', $args['html_name'] )
		);

Parameters

  1. $preg_replace


Usage

The following example is for adding a hook callback.

// define the wpcf7_form_name_attr callback 
function custom_wpcf7_form_name_attr( $preg_replace ){ 
   //custom code here
    return $preg_replace
} 

//add the action 
add_filter('wpcf7_form_name_attr', 'custom_wpcf7_form_name_attr', 10, 1)

Defined

The filter is defined in the following location(s).

contact-form-7/includes/contact-form.php

$name_attr = apply_filters( 'wpcf7_form_name_attr',
			preg_replace( '/[^A-Za-z0-9:._-]/', '', $args['html_name'] )
		);