Support » Plugin: Contact Form 7 Dynamic Text Extension » Adding shortcode for case-insensitive url param extraction

  • Resolved yositsitsu

    (@yositsitsu)


    Hi and thanks for this awesome plugin!

    Saved me hours!

    Please 2 suggestions:

    1. adding ability to add onclick JS to fields

    2. adding shortcode for case-insensitive url param extraction

    I needed badly to make it case insensitive immediately, so changed the code myself, which is of course bad, as it it will be overridden with next version 🙂

    Here is what I did:

    
    /* Insert a $_GET variable */
    function cf7_get($atts){
    	extract(shortcode_atts(array(
    		'key' => 0,
    	), $atts));
    	$value = '';
    	// make it case insensitive
    	$_GET_lower = array_change_key_case($_GET, CASE_LOWER);
    
    	$key = strtolower( $key );
    	if( isset( $_GET_lower[$key] ) ){
    		$value = urldecode($_GET_lower[$key]);
    	}
    	return $value;
    }
    

    Thanks!
    Yosi

Viewing 1 replies (of 1 total)
  • Plugin Author sevenspark

    (@sevenspark)

    Hi Yosi,

    Glad you’re liking the plugin!

    1. Right now, the plugin is strictly server side. May experiment with dynamic client side values in the future

    2. The beauty of it is that you can create your own custom shortcode – so just copy the code into your child theme, rename the shortcode and function code so it doesn’t conflict with what is provided by the theme, and then use your new shortcode in your form tag 🙂

    Best,

    Chris

Viewing 1 replies (of 1 total)
  • The topic ‘Adding shortcode for case-insensitive url param extraction’ is closed to new replies.