maehdros
Forum Replies Created
-
Forum: Plugins
In reply to: [Contact Form 7] Checkbox emptyI was experiencing the same issue and was about to report it. Thank you for taking care Takayuki!
Cheers
Forum: Plugins
In reply to: [Contact Form 7] Custom validation filter stucks form validationWell, at this point, I’ve arrived to a code that is working without bugs, but it keeps failing in its purpose:
add_filter( 'wpcf7_validate_checkbox*', 'user_plan_validation_filter', 20, 2 ); function user_plan_validation_filter( $result, $tag ) { $tag = new WPCF7_Shortcode( $tag ); $field = 'user-plan'; if ( $field == $tag->name ): if ( isset( $_POST['user-plan'] ) ): $user_plan = trim( $_POST['user-plan'] ); else: $user_plan = ''; endif; if ( $user_plan == '' ): $result->invalidate( $tag, "Selecciona un plan para poder finalizar el tramite" ); endif; endif; return $result; }Using the PHP Error Log I checked that all the variables are being filled with the values I expect, the conditional sentences also are working as expected, but the validation message keeps showing the one setted in the Contact Form configuration.
Any help?
Thanks!
Forum: Plugins
In reply to: [Contact Form 7] Custom validation filter stucks form validationSome debug information I pulled out from “debug.log”:
[10-Nov-2016 17:09:58 UTC] PHP Notice: Undefined index: user-plan in /home/mcmovil/public_html/wp-content/themes/mcmovil-theme/functions.php on line 212Line 212 is this:
$user_plan = $_POST['user-plan'];Sorry for the commented line in the previous post code, I forgot to clean it.
Forum: Plugins
In reply to: [Contact Form 7] Custom validation filter stucks form validationGot it! That bug is solved. Here’s the code:
add_filter( 'wpcf7_validate_checkbox*', 'user_plan_validation_filter', 10, 2 ); function user_plan_validation_filter( $result, $tag ) { $tag = new WPCF7_Shortcode( $tag ); if ( $tag->name == 'user-plan' ) { $user_plan = $_POST['user-plan']; // $user_plan = isset( $_POST['user-plan'] ) ? trim( $_POST['user-plan'] ) : ''; if ( $user_plan == '' ) { $result->invalidate( $tag, "Selecciona un plan para poder finalizar el tramite" ); } } return $result; }Now the validation process doesn’t get stuck, but the validation message shown is not my custom one but the one set in the form options. What can I be doing wrong?
Thanks a lot for your help Takayuki, cheers!
Forum: Plugins
In reply to: [Contact Form 7] Custom validation filter stucks form validationHi! Takayuki, thanks for your excellent work with Contact Form 7, it’s a tremendous helper in my jobs.
Here’s the error logged:
[Fatal error] => 09.11.2016 16:47:20 Cannot use object of type WPCF7_Shortcode as array in /home/mcmovil/public_html/wp-content/themes/mcmovil-theme/functions.php (209)The “line 209” is this:
if ( $tag['name'] == 'user-plan' ) {Cheers!
- This reply was modified 9 years, 7 months ago by maehdros.
Thank you very much for this post! I’m in the quest of adding the “billing_country” select drop-down menu to the registration form, I’ll keep you up with this.
Cheers!