Casemon
Forum Replies Created
-
Forum: Plugins
In reply to: Contact Form 7 Input Fields Values as PHP Get-ViarablesAny chance of getting this behavior rolled into the release code?
Having to manually add this feature with every release is tiresome and counter productive to using 3rd party plugins.
Forum: Plugins
In reply to: [contact form 7] using custom fields [select]Wish this were rolled into the release code…
Modifying plugins willy-nilly is a big no-no in my book.
Forum: Plugins
In reply to: Postie won’t activate on WP 2.9.2?Fixed in v1.4.1 woot!
It would seem so, I’m not so well versed in all this.
@titusbicknell
post your adaptation of the code and we’ll go from there!More specifically please?
What am I looking for here? And what more, how do I get what I don’t know I’m looking for to result in the desired behavior?
Hmm can you provide more details?
Not sure what I’m looking for here, much less how to leverage what I find if I do find what I don’t know what I’m looking for ??
Actually it does work, but only when the shortcode appears in the form; the shortcode doesn’t work in the mail fields…
Any idea why?
Ok, have managed to get this working partially. Ended up making a franken-add-on based on the various other modules.
The good:
Am seeing the value of the custom field if I include [customfield some-custom-field-name] in the form. Great.The bad / not working:
If I add the customfield tag name to the Additional headers: area (the desired custom field happens to be an email) as in CC: [some-custom-field-name] <some-custom-field-email]>then the CC field is blank! The email has a blank entry for CC, as shown:
Blank CC entry in resulting mail…Anyone know why this is?
Here’s the module code if it helps:
<?php /** ** contact form 7 module, which enables you to get the result of a custom field from the page that the form is on ** [customfield name] -> returns the value of a custom field on that post/page for [name] **/ /* Shortcode handler */ /* Shortcode handler */ wpcf7_add_shortcode( 'customfield', 'wpcf7_customfield_shortcode_handler', true ); function wpcf7_customfield_shortcode_handler($field) { global $wpcf7_contact_form; global $wp_query; $thePostID = $wp_query->post->ID; $somefield = get_post_meta($thePostID, $field[name], true); if (empty($somefield)) return ''; return $somefield; } add_filter( 'wpcf7_validate_customfield', 'wpcf7_customfield_validation_filter', 10, 2 ); function wpcf7_customfield_validation_filter( $result, $tag ) { global $wpcf7_contact_form; // $type = $tag['type']; $name = $tag['name']; $_POST[$name] = trim( strtr( (string) $_POST[$name], "\n", " " ) ); return $result; } /* Tag generator */ add_action( 'admin_init', 'wpcf7_add_tag_generator_customfield', 15 ); function wpcf7_add_tag_generator_customfield() { wpcf7_add_tag_generator( 'customfield', __( 'Custom Field', 'wpcf7' ), 'wpcf7-tg-pane-customfield', 'wpcf7_tg_pane_customfield' ); } function wpcf7_tg_pane_customfield( $type = 'customfield' ) { $type = 'customfield'; ?> <div id="wpcf7-tg-pane-<?php echo $type; ?>" class="hidden"> <form action=""> <table> <tr><td><input type="checkbox" name="required" /> <?php echo esc_html( __( 'Required field?', 'wpcf7' ) ); ?></td></tr> <tr><td><?php echo esc_html( __( 'Name', 'wpcf7' ) ); ?><br /><input type="text" name="name" class="tg-name oneline" /></td><td></td></tr> </table> <table> <tr> <td><code>id</code> (<?php echo esc_html( __( 'optional', 'wpcf7' ) ); ?>)<br /> <input type="text" name="id" class="idvalue oneline option" /></td> <td><code>class</code> (<?php echo esc_html( __( 'optional', 'wpcf7' ) ); ?>)<br /> <input type="text" name="class" class="classvalue oneline option" /></td> </tr> <tr> <td><code>size</code> (<?php echo esc_html( __( 'optional', 'wpcf7' ) ); ?>)<br /> <input type="text" name="size" class="numeric oneline option" /></td> <td><code>maxlength</code> (<?php echo esc_html( __( 'optional', 'wpcf7' ) ); ?>)<br /> <input type="text" name="maxlength" class="numeric oneline option" /></td> </tr> <tr> <td><?php echo esc_html( __( 'Akismet', 'wpcf7' ) ); ?> (<?php echo esc_html( __( 'optional', 'wpcf7' ) ); ?>)<br /> <?php if ( 'customfield' == $type ) : ?> <input type="checkbox" name="akismet:author" class="exclusive option" /> <?php echo esc_html( __( "This field requires author's name", 'wpcf7' ) ); ?><br /> <input type="checkbox" name="akismet:author_url" class="exclusive option" /> <?php echo esc_html( __( "This field requires author's URL", 'wpcf7' ) ); ?> <?php endif; ?> </td> <td><?php echo esc_html( __( 'Default value', 'wpcf7' ) ); ?> (<?php echo esc_html( __( 'optional', 'wpcf7' ) ); ?>)<br /><input type="text" name="values" class="oneline" /></td> </tr> </table> <div class="tg-tag"><?php echo esc_html( __( "Copy this code and paste it into the form left.", 'wpcf7' ) ); ?><br /><input type="text" name="<?php echo $type; ?>" class="tag" readonly="readonly" onfocus="this.select()" /></div> <div class="tg-mail-tag"><?php echo esc_html( __( "And, put this code into the Mail fields below.", 'wpcf7' ) ); ?><br /><span class="arrow">⬇</span> <input type="text" class="mail-tag" readonly="readonly" onfocus="this.select()" /></div> </form> </div> <?php } ?>
@1manfactory
Thanks for this, it’s a good start.Am stuck on 1 thing:
1) getting the page ID into my custom shortcode function; you cannot pass [_post_id] within a shortcode as far as I can tell, and $post->ID doesn’t work in the shortcode function (not sure why).
Am happy to extend CF7, though really wish there was some documentation on all this, can’t seem to find API info on CF7.
Is there any more documentation on creating an add-on module?
Anyone?
If it helps, seems to not exhibit the above if using a different header:
Reply-To: some name <[email protected]>
Forum: Plugins
In reply to: [Plugin: Contact Form 7] reply-to address does not workIf it helps, GCorwin’s solution works here.
Forum: Plugins
In reply to: [Plugin: Search Everything] Sort results?Nevermind, added this to functions.php in my theme:
`/* sort search results by title */
function sort_searchresult_by_title($k) {
if(is_search()) {
$k->query_vars[‘orderby’] = ‘title’;
$k->query_vars[‘order’] = ‘ASC’;
}
}
add_action(‘pre_get_posts’,’sort_searchresult_by_title’);’Works like a charm! ??