Mad Max
Forum Replies Created
-
@sttc
Please edit the post and mvoe your code to a place like pastebin.com, then post a link to the code.
The steps you’ve listed are ok. Double check function name: name used in the add_filter call must match with the defined function name.
If it seems all ok, there should be some erro in the logic of your code. Just to start, try to invert the condition you are using to check for duplicates, to see if something happens or use firefox+firebug to debug.@stcc
Sure, you have to add the code above in your function.php theme file or create one if your theme doesn’t already include it, and put the code between the open and close php tags:<?php //code here ?>Change the relevant data in the code (form name, field name, error message etc) and it should work as is.
Forum: Fixing WordPress
In reply to: Explanation and workaround for error 404 on category paginationHappy to hear that from all you guys! Hope to find some spare time to code this in a plugin, or better find that the last WP versione has resolved this issue (Hope springs eternal!).
Forum: Plugins
In reply to: [Search Everything] [Plugin: Search Everything] Is there a Changelog?Well, while we are waiting for a changelog here, we can check the github page of the project.
The last update seems to contain some code improvements and bugfixes for the backend.Well, just for the sake of completeness, here is the same code but using Michael’s API to access form data in the db:
// Add custom validation for CF7 form fields function is_coupon_already_requested($email){ // Check if a customer has already request a discount coupon define ('FORM_NAME', 'Coupon'); define ('FIELD_NAME', 'coupon_email'); if (empty($email)) return false; $findit=false; require_once(ABSPATH . 'wp-content/plugins/contact-form-7-to-database-extension/CFDBFormIterator.php'); $exp = new CFDBFormIterator(); $exp->export(FORM_NAME, array('show' => FIELD_NAME, 'search' => $email)); while ($row = $exp->nextRow()) { $findit=true; } return $findit; } function duplicate_email_validation_filter($result,$tag){ define ('FIELD_NAME', 'coupon_email'); $type = $tag['type']; $name = $tag['name']; if($name == FIELD_NAME){ // Only apply to fields with the form field name of "coupon_email" $the_value = $_POST[$name]; if( !empty($the_value) && is_coupon_already_requested($the_value)){ //An user with this email has already received a coupon) $result['valid'] = false; $result['reason'][$name] = 'Email address already used.'; } } return $result; } add_filter('wpcf7_validate_email','duplicate_email_validation_filter', 10, 2); // Email field add_filter('wpcf7_validate_email*', 'duplicate_email_validation_filter', 10, 2); // Req. Email fieldN.B.: Please note that if you pass an empty string as search value to the API, it returns all unfiltered rows for that query.
This is the reason why I added a check to see if the email field is empty or not.Thanks Michael, I wasn’t aware of this API. Great support, as usual!
Don’t know if someone is interested in this isssue any more, but I’ve find a way to make data validation against db submissions.
Thanks to this post, I’ve created a custom email validation function to avoid customers of one of my sites, to request more than one discount coupon with the same email address.
PLEASE NOTE: there’s no way to apply this custom validation to a particular form (i.e form id) cause the form id is not a parameter we can check using those validation filters.
So, if you have more then one form and you want to apply the custom validation only to a particular form, the only way I know is to use a univocal field name, or programmaticaly create a new type of field to use in your form and for your custom validation.
Obviously, every form using that field-id or that field-name, will make use of the custom validation function.So, here is my code:
// Add custom validation for CF7 form fields function is_coupon_already_requested($email){ // Check if a customer has already request a discount coupon global $wpdb; define ('FORM_NAME', 'Coupon'); define ('FIELD_NAME', 'coupon_email'); $query="SELECT submit_time, if(field_name='".FIELD_NAME."', field_value, null ) AS '".FIELD_NAME."' FROM ss_cf7dbplugin_submits WHERE form_name = '".FORM_NAME."' AND field_value='".$email."' "; $myrows = $wpdb->get_results( $query, ARRAY_A ); if (is_array($myrows) && count($myrows)){ return true; //email already exists in the db }else{ return false; // first time with this email } } function duplicate_email_validation_filter($result,$tag){ define ('FIELD_NAME', 'coupon_email'); $type = $tag['type']; $name = $tag['name']; if($name == FIELD_NAME){ // Only apply to fields with the form field name of "coupon_email" $the_value = $_POST[$name]; if(is_coupon_already_requested($the_value)){ //An user with this email has already received a coupon) $result['valid'] = false; $result['reason'][$name] = 'Email address already used.'; } } return $result; } add_filter('wpcf7_validate_email','duplicate_email_validation_filter', 10, 2); // Email field add_filter('wpcf7_validate_email*', 'duplicate_email_validation_filter', 10, 2); // Req. Email fieldHope it can be useful
Forum: Plugins
In reply to: [Search Everything] [Plugin: Search Everything] Is there a Changelog?+1 for this request. I’d like to know which new features or bugfixes are present in a new version when I make an update.
Blind-update on a customer site could be a nightmare…Ah, topic resolved!
Thanks for your reply. You are right about cache: it was a caching problem, but was my fault: I’ve upgraded your plugin and then I forgot to clear W3TC cache, so the plugin was serving old data to non logged users (logged users always get fresh data).
Thanks again for your plugin and your support.
Forum: Plugins
In reply to: [Rich Text Tags] [Plugin: Rich Text Tags] Change password fields disappearsGraet Zack!! Thanks a lot!
Forum: Plugins
In reply to: [Rich Text Tags] [Plugin: Rich Text Tags] Change password fields disappearsSame thing here: WordPress 3.3.2 with RTT 1.6.2
the password input fields just disappeared! I can’t change a user password anymore.
If I deactivate RTT, password input fields are there again.
Any idea about it?
Forum: Plugins
In reply to: Rotating/Cropping image does not work for custom image sizesI’ve added a few lines of code to take care of youtu.be urls. Just add the code below in vipers-vide-quicktags.php on line #2871
// Short/Share url ( http://youtu.be/videoid[?whatever=xx] ) elseif ( FALSE !== stristr( $content, 'youtu.be' ) ) { $parsed_url=parse_url($content); $videoid=basename($parsed_url['path']); $embedpath = 'v/' . $videoid; $fallbacklink = 'http://www.youtube.com/watch?v=' . $videoid; $fallbackcontent = '<img src="http://img.youtube.com/vi/' . $videoid . '/0.jpg" alt="' . __('YouTube Preview Image', 'vipers-video-quicktags') . '" />'; }It also ignores query string parameters like t=xx added by youtube when a user selects a start time in the video.
Hope the plugin author could add those patch to the source code.
I’ve added a few lines of code to take care of youtu.be urls. Just add the code below in vipers-vide-quicktags.php on line #2871
// Short/Share url ( http://youtu.be/videoid[?whatever=xx] ) elseif ( FALSE !== stristr( $content, 'youtu.be' ) ) { $parsed_url=parse_url($content); $videoid=basename($parsed_url['path']); $embedpath = 'v/' . $videoid; $fallbacklink = 'http://www.youtube.com/watch?v=' . $videoid; $fallbackcontent = '<img src="http://img.youtube.com/vi/' . $videoid . '/0.jpg" alt="' . __('YouTube Preview Image', 'vipers-video-quicktags') . '" />'; }It also ignores query string parameters like t=xx added by youtube when a user selects a start time in the video.
Hope the plugin author could add those patch to the source code.