Forums

[Plugin: Contact Form 7] Prefill certain fields from linkedin? (3 posts)

  1. DDT
    Member
    Posted 11 months ago #

    Hi,

    I have made a simple script which graps some basic information from linkedin if a user authorize the app. Now with a plain form i now how to prefill the form fields, but i like to use CF7.

    What is the best way to prefill a form with CF7??

    Any info?

  2. Kevin Ernst
    Member
    Posted 7 months ago #

    Possibly this: Contact Form 7 Dynamic Text Extension.

    There also seem to be some ideas here, but they seem to involve hacking at the Contact Form 7 code, which most people will tell you is inadvisable (you lose your changes when the plugin gets updated).

    I have to do the same thing with an online (animal) adoptions application. If have any great revelations in the process, I'll post a follow-up here.

  3. guidokritz
    Member
    Posted 6 months ago #

    Hi! You can use this code I wrote. Is kinda hacky but is better than
    hacking the plugin core code or rely on javascript tricks. Hope someone find this useful.

    function cfvalues( $a ) {
    	$field_name = 'subject';
    	$default_value = 'custom';
    	if ( preg_match_all( '/<input.*?name="' . $field_name . '".*?\/>/', $a, $match ) ) {
    		$subject = $match[ 0 ][ 0 ];
    		$new_subject = preg_replace( '/value=""/', 'value="' . $default_value . '"', $subject );
    		$a = str_replace( $subject, $new_subject, $a );
    	}
    	return $a;
    }
    add_filter( 'wpcf7_form_elements', 'cfvalues' );

Reply

You must log in to post.

About this Topic