absolutist
Forum Replies Created
-
Forum: Plugins
In reply to: [Email Before Download] CF7 and EBD not workingI have the same problem. The plugin always renders
<html><body>
tags around the form, which makes no sense at all.The class
Email_Before_Download_Form
has a method namedhtml()
which contains the line$form->loadHTML('<?xml encoding="utf-8" ?>'.$raw);
, which automatically adds the html and body tags around the html.Change it to this:
$form->loadHTML('<?xml encoding="utf-8" ?>'.$raw, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
and it will not add those tags.Could this be fixed in a next version?
Forum: Plugins
In reply to: [Email Before Download] Error when not using your-email or your-name fieldsSorry, I totally got that wrong. You can get the posted data, with all the filters applied, by using:
$submission = WPCF7_Submission::get_instance(); $user_data = $submission->get_posted_data();
It would be great of that could be implemented.
Forum: Plugins
In reply to: [Email Before Download] Error when not using your-email or your-name fieldsAllright, I did some more testing. The hooks solution doesn’t work, because the plugin takes the $_POST data directly. The problem lies in the Email_Before_Download_Process class.
This part specifically:
public function process_cf7($form_obj) { if (!isset($_POST['ebd_settings'])) { return $form_obj; // make sure this only fires when there is EBD info } $post_data = $_POST; $user_input = []; $settings = $this->parse_post_array($post_data['ebd_settings']); $downloads = $this->parse_post_array($post_data['ebd_downloads']); foreach ($post_data as $key => $value) { if (!is_array($value)) $user_input[$key] = $value; } $this->log($post_data, $user_input); ...
All CF7 hooks are skipped like this. CF7 does the following in their WPCF7_Submission class:
private function setup_posted_data() { $posted_data = (array) $_POST; $posted_data = array_diff_key( $posted_data, array( '_wpnonce' => '' ) ); $posted_data = $this->sanitize_posted_data( $posted_data ); $tags = $this->contact_form->scan_form_tags(); foreach ( (array) $tags as $tag ) { if ( empty( $tag['name'] ) ) { continue; } $name = $tag['name']; $value = ''; if ( isset( $posted_data[$name] ) ) { $value = $posted_data[$name]; } $pipes = $tag['pipes']; if ( WPCF7_USE_PIPE && $pipes instanceof WPCF7_Pipes && ! $pipes->zero() ) { if ( is_array( $value) ) { $new_value = array(); foreach ( $value as $v ) { $new_value[] = $pipes->do_pipe( wp_unslash( $v ) ); } $value = $new_value; } else { $value = $pipes->do_pipe( wp_unslash( $value ) ); } } $posted_data[$name] = $value; } $this->posted_data = apply_filters( 'wpcf7_posted_data', $posted_data ); return $this->posted_data; }
Wouldn’t something similar be a better way to get all the data? For instance:
$submission = WPCF7_Submission::get_instance($form_obj, ['skip_mail' => true]); $posted_data = $submission->get_posted_data();
- This reply was modified 6 years, 10 months ago by absolutist.
Forum: Plugins
In reply to: [Email Before Download] Error when not using your-email or your-name fieldsThanks for the quick reply ??
I’m using a “first name” and “last name” field in my form. Contact Form 7 has hooks, but are those fired before EBD does it’s work? If so, I could always add a “fake your-name field” in a hook by combining the first and last name fields.
(Don’t know about my post formatting, I’ve used the default backticks for code… Seems you got my point though)