Sunday 15 July 2012

wordpress - check if user email exists, and if not, stop the submit of the ninja form -



wordpress - check if user email exists, and if not, stop the submit of the ninja form -

i've 1 form built ninja forms, , utilize ajax send it. i need check if email introduced exists in database (user_email), , if exists properly, send form properly, if doesn't exist, form isn't submitted, , need give user message "email not exist". the form survey completed registered user, gives feedback our services, survey located in page user can send sentiment without needed logged.

i'm investigating, , @ moment have:

function example_disable_saving_subs( $save, $form_id ) { global $ninja_forms_processing; $form_id = $ninja_forms_processing->get_form_id(); $email = ninja_forms_get_field_by_id( 18 ); //cuestionario feedback profesor sobre creación de united nations curso if($form_id == 3){ if( !email_exists( $email )) { $save = false; $ninja_forms_processing->add_error('email_no_existe', 'el email no existe'); } } homecoming $save; } add_filter( 'ninja_forms_save_submission', 'example_disable_saving_subs', 2, 10 );

but pick field $email without value introduced...in addition, don't know way give user message "email not exists".

as see, chose filter ninja_forms_save_submission. maybe not right filter. hope valious help. in advance, daniel

thanks help @renato , give +1 :) it's true can through way tell me, i don't want break api of wordpress, is, way cms uses javascript, php, etc etc...so, wanted through api of ninja forms, plugin utilize build survey. finally, solved it...it mistake, because didn't utilize right filter...investigating few more, there's filter much more appropiate: ninja_forms_pre_process here code:

function add_change_ninja_forms_landing_page(){ add_action( 'ninja_forms_pre_process', 'handle_custom_ninja_forms' ); } add_action( 'init', 'add_change_ninja_forms_landing_page' ); function handle_custom_ninja_forms(){ global $ninja_forms_processing; $form_id = $ninja_forms_processing->get_form_id(); //if it's form of survey if( $form_id == 3 ){ $email = $ninja_forms_processing->get_field_value( 18 ); //pick value of email field //use native function of wordpress check if there's user email //is has email, not exist if( !email_exists( $email )) { $ninja_forms_processing->add_error('email_no_existe', 'el email indicado no está registrado en nuestra base of operations de datos'); //add_error stop form , gives error message } } }

with code above works fine! :) thanks!

wordpress forms survey

No comments:

Post a Comment