WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
Pipes : get before value (14 posts)

  1. leup
    Member
    Posted 3 years ago #

    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 :

    http://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.

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

  2. leup
    Member
    Posted 3 years ago #

    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. :)

  3. dotblend
    Member
    Posted 3 years ago #

    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?

  4. leup
    Member
    Posted 3 years ago #

    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.

  5. dotblend
    Member
    Posted 3 years ago #

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

    this should be embedded into the source on cf7

  6. leup
    Member
    Posted 3 years ago #

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

  7. Takayuki Miyoshi
    Member
    Plugin Author

    Posted 3 years ago #

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

  8. dotblend
    Member
    Posted 3 years ago #

    it stopped working, leup HELP!!!!

  9. leup
    Member
    Posted 3 years ago #

    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

  10. stoomey
    Member
    Posted 3 years ago #

    Thanks so much leup, your plugin works like a charm! :-)

  11. Jacob Dunn
    Member
    Posted 3 years ago #

    Quick correction : the url above has a missing /

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

    Thanks for the plugin!

  12. whoaloic
    Member
    Posted 2 years ago #

    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 ) );
    				}
    			}
  13. leup
    Member
    Posted 2 years ago #

    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.

  14. whoaloic
    Member
    Posted 2 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic