Support » Plugin: Contact Form 7 » Request: Set _post_url and _post_title in Javascript

  • In many cases, the automatic mail tags for the page URL and title cannot be set, because the form is displays outside “the loop”.

    To cater for cases like this, it’s possible to add these to the form as hidden fields and use Javascript to set them.

    This code works for me (using custom field names):

    
    jQuery(document).ready(function() {
    	var page_url = jQuery(location).attr('href');
    	var page_title = jQuery(document).attr('title');
    	jQuery('#page_url').val(page_url);
    	jQuery('#page_title').val(page_title);
    });
    
  • You must be logged in to reply to this topic.