如何在提交忍者表单时调用php函数?

时间:2015-04-17 08:36:13

标签: php wordpress wordpress-plugin

我在我的Wordpress网站上添加了一个ninja_form,我需要在提交这个ninja_form时调用php函数,我该怎么做?

感谢您的回复

1 个答案:

答案 0 :(得分:3)

<?php
function ninja_forms_register_example(){
  add_action( 'ninja_forms_process', 'ninja_forms_example' );
}
add_action( 'init', 'ninja_forms_register_example' );

function ninja_forms_example(){
  global $ninja_forms_processing;

  //Get all the user submitted values
  $all_fields = $ninja_forms_processing->get_all_fields();

  if( is_array( $all_fields ) ){ //Make sure $all_fields is an array.
  //Loop through each of our submitted values.
    foreach( $all_fields as $field_id => $user_value ){
      //Do something with those values
    }
  }
}`

http://docs.ninjaforms.com/article/105-ninjaformsprocess