wordpress - Add a custom field to Contact Form 7 tag -
well, may have misunderstood want , :
this how cf7 register text fields shorttags :
add_action( 'wpcf7_init', 'wpcf7_add_shortcode_text' ); function wpcf7_add_shortcode_text() { wpcf7_add_shortcode( array( 'text', 'text*', 'email', 'email*', 'url', 'url*', 'tel', 'tel*' ), 'wpcf7_text_shortcode_handler', true ); }
note hook wpcf7_init
function wpcf7_add_shortcode()
, if make our own example :
add_action( 'wpcf7_init', 'custom_add_shortcode_hello' ); function custom_add_shortcode_hello() { wpcf7_add_shortcode( 'helloworld', 'custom_hello_shortcode_handler' ); // "helloworld" type of form-tag }
and callback handler
function custom_hello_shortcode_handler( $tag ) { return 'hello world ! '; }
now if add in form
cf7 : [helloworld]
you should see
cf7 : hello world !
if want use normal form tags , note available default types :
text, text*, email, email*, tel, tel*, url, url*, textarea ,textarea* , number, number*, range , range* , date , date*,checkbox, checkbox*, radio, select , select* , file , file*, captchac ,captchar, quiz , acceptance, submit;
now, wrote this, because far know ( , might wrong ) there no filter html form existing tag defined in function wpcf7_tg_pane_text_and_relatives()
in modules/text.php
, can remove default tag ( example text ) using wpcf7_remove_shortcode( $tag );
, add own adapting example above need creating new 1 ( example text )
that being said , not sure yet , why want ( did not explained goal, way ) because imho , , after lot of cf7 custom plugins wrote , not understand why not create new tag , easier , more constructed .
but again, might wrong .
Comments
Post a Comment