WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
Using [wpcf7.remote_ip] With Custom Feild (6 posts)

  1. biastechnology
    Member
    Posted 1 year ago #

    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.]

  2. biastechnology
    Member
    Posted 1 year ago #

    Hi Anyone have any ideas?

    Thanks

  3. biastechnology
    Member
    Posted 1 year ago #

    Hi guys, I'm still having trouble with this.

    Any Help?

    Thanks

  4. biastechnology
    Member
    Posted 1 year ago #

    REPOST

    Hi guys, I'm still having trouble with this.

    Any Help?

    Thanks

  5. D.Q
    Member
    Posted 1 year ago #

  6. biastechnology
    Member
    Posted 1 year ago #

    Hi D.Q,

    Thanks for the link.

    I've tried that, and when I use the [wpcf7.remote_ip] in the main message area, I just get back my custom variable for my custom field [Get_RMA].

    I'm hoping that Takayuki Miyoshi will see this and offer some help.

    Cheers

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic