I have a form with one text field Phone Number. I want to perform a custom action with this field. How do I access the submitted field in this code?

function wpf_custom_form_action( $action, $form_data) {  

 if ( $form_data[ 'id' ] == '168' ) {
     return "somesite.com";
    return $action;

1 Answer 1


Would likely be available in one of the function parameters (most likely $form_data), or the global $_POST variable.

  • I tried $_POST[0] but it was empty
    – SanSolo
    Jun 9, 2023 at 2:34
  • 1
    It's unlikely the array would have numerical keys. Try var_dump( $_POST ) to see if there's data there. If not, then try dumping the function parameters to see what's in there.
    – Caleb
    Jun 9, 2023 at 2:35
  • Thank you so much. This gives me hope. The var_dump result is: array(1) { [“wpforms”]=> array(6) { [“author”]=> string(1) “2” [“post_id”]=> string(1) “2” [“submit”]=> string(14) “wpforms-submit” [“token”]=> string(32) “6fa83de7b7c61abfa5c22d20e80348f3” [“complete”]=> array(1) { [2]=> array(4) { [“name”]=> string(12) “Phone Number” [“value”]=> string(4) “9123” [“id”]=> int(2) [“type”]=> string(4) “text” } } [“entry_id”]=> int(0) } }
    – SanSolo
    Jun 9, 2023 at 2:44
  • Yep, that looks like it contains submitted form data. You're welcome. Please mark this answer as accepted if you are able.
    – Caleb
    Jun 9, 2023 at 2:47
  • 1
    Looks like the offsets would be this: $_POST['wpforms']['complete'][2]['value']. I recommend checking the function parameters though: the same data may be there in an easier structure.
    – Caleb
    Jun 9, 2023 at 2:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.