• Hi !

    i don’t know if this topic has already been discussed but this is how i achieve to get the “before” value of pipes.

    I use pipes for choising recipients depending on the subject as described here :

    https://contactform7.com/2009/11/26/selectable-recipient-with-pipes/

    but i wanted to set the subject of the sented email with the choosen label.

    What i did is to modify the file ‘includes/classes.php’ in the mail() function and replace l. 308-321 by :

    if ( WPCF7_USE_PIPE && is_a( $pipes, 'WPCF7_Pipes' ) && ! $pipes->zero() ) {
      $this->posted_data[$name.':before'] = $value;
      if ( is_array( $value) ) {
        $new_value = array();
        foreach ( $value as $v ) {
          $new_value[] = $pipes->do_pipe( stripslashes( $v ) );
          $new_value_before[] = $v;
        }
        $value = $new_value;
        $this->posted_data[$name.':before'] = $new_value_before;
      }
      else {
        $value = $pipes->do_pipe( stripslashes( $value ) );
      }
    }

    And now, i can use the following shortcode :

    [your-subject:before] to output the label of ‘your-subject’ instead of the value.

    It’s maybe not a very good way to achieve this. It really is a quick and dirty mod but for me, it works.

    https://www.ads-software.com/extend/plugins/contact-form-7/

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter leup

    (@leup)

    Wouldn’t it be useful to add something like this to the plug-in ?

    I ask because i would like to see this feature in the plugin and be able to upgrade it without having to patch it every time. ??

    Hi Leup,
    thanks for this excellent piece of code, but somehow i cant get it to work,
    i must be silly or something but could yo please sent me a working copy of your classes.php (zipped) because it gives me serious headache end the following error..

    Parse error: syntax error, unexpected ';', expecting T_FUNCTION in wp-content/plugins/contact-form-7/includes/classes.php on line 639

    any clues?

    Thread Starter leup

    (@leup)

    Hi dotblend,

    don’t know why you get this error.

    This is my classes.php based on the latest version of cf7 :

    cf7_classes.zip

    I hope it will help you.

    it worked!!!! yeah!!!!! you are so awesome!!!!!!!

    this should be embedded into the source on cf7

    Thread Starter leup

    (@leup)

    You’re welcome. I would like to see it (or something like that) into the source too as upgrading could not be done automatically…

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    You can make it an independent plugin as Contact Form 7 to Database Extension is.

    it stopped working, leup HELP!!!!

    Thread Starter leup

    (@leup)

    Hi dotblend,

    I’m sorry but there is no reason why it does not work anymore. Are you sure you did not have launch an automatic update which could have delete your modifications ?

    I made a plugin as suggested by Miyoshi


    http:/glasshouse.fr/dnload/contact-form-7-beforepipe.zip

    Thanks so much leup, your plugin works like a charm! ??

    Quick correction : the url above has a missing /

    Correct URL:
    https://glasshouse.fr/dnload/contact-form-7-beforepipe.zip

    Thanks for the plugin!

    Hello!
    thank you for this!
    but where to add the file contact-form-7-beforepipe.php ?

    Do we have to erase following lines of the include/classes.php file?

    if ( WPCF7_USE_PIPE && is_a( $pipes, 'WPCF7_Pipes' ) && ! $pipes->zero() ) {
    				if ( is_array( $value) ) {
    					$new_value = array();
    					foreach ( $value as $v ) {
    						$new_value[] = $pipes->do_pipe( stripslashes( $v ) );
    					}
    					$value = $new_value;
    				} else {
    					$value = $pipes->do_pipe( stripslashes( $value ) );
    				}
    			}
    Thread Starter leup

    (@leup)

    Hi !

    This is a plugin. So you just have to unzip it in your wp-content/plugins folder and activate it in your plugins admin area.

    I did not test it with the last version (3.0..) of Contact Form 7 by the way.

    All right! It works with the last version.
    Thank you!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘[Plugin: Contact Form 7] Pipes : get before value’ is closed to new replies.