Support » Plugin: Contact Form 7 » Using [wpcf7.remote_ip] With Custom Feild

  • Hi All,

    I’m having trouble calling the [wpcf7.remote_ip] function because I’ve used the below code to add a custom field.

    /**
    *Add RMA to Database
    */
    add_action( 'wpcf7_mail_sent', 'your_wpcf7_mail_sent_function' );
    function your_wpcf7_mail_sent_function( $contact_form ) {
    	global $wpdb;
    	$title = $contact_form->title;
    	$posted_data = $contact_form->posted_data;
    	if ( 'RequestRMA' == $title ) {
    		$company_name = $posted_data['CompanyName'];
    		$sql = $wpdb->prepare("INSERT INTO wp_rma(company_name) VALUES (%s)", $company_name);
    		$wpdb->query($sql);
    	}
    }
    /**
    *Get RMA From Database
    */
    add_filter( 'wpcf7_special_mail_tags', 'your_wpcf7_special_mail_tag_extension', 10,2);
    function your_wpcf7_special_mail_tag_extension( $outputs, $names ) {
    	global $wpdb;
    		if ( 'Get_RMA' == $names )
    			$RMA = 'Error - Please Contact 01234 567890';
    			$outputs=$wpdb->get_var( $wpdb->prepare("SELECT RMA_ID FROM wp_rma ORDER BY time_date_stamp DESC LIMIT 1"));
    		return ($outputs);
    }

    When this code is used in functions.php the [wpcf7.remote_ip] function now outputs the ‘Get_RMA’ rather than the ip address of the user.

    How can I keep my custom field and use the [wpcf7.remote_ip] short code to display the users IP address?

    Any help would be great.
    If you need more info just ask.

    http://wordpress.org/extend/plugins/contact-form-7/

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. Or better still – use a pastebin. As it stands, your posted code may now have been permanently damaged/corrupted by the forum’s parser.]

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Using [wpcf7.remote_ip] With Custom Feild’ is closed to new replies.