PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Modifying data before inserting into user registration table.

  1. Hi,

    I am using the User registration add-on and am trying to edit one of my custom meta fields (the phone field. I have this mostly working.

    I'm using this function to get the phone data and strip all non numeric characters. The problem is I'm unsure how to send my modified data back to the meta data before it's inserted into the WP user_meta table.

    add_action("gform_pre_submission_1", "ba_signup_pre_submission_handler");
    function ba_signup_pre_submission_handler($form_meta){
      	//handling single-input fields such as text and paragraph (textarea)
            // get data from forum
            $phone = $_POST["input_3"];
           //strip off all non-numbers
            $phone_numbers = preg_replace("/[^0-9]/", "", $phone );
            //send back to add-on (this step isnt' working)
            $_POST["input_3"] = $phone_numbers;
    }

    I know the first two steps are working it's just the sending back that's a problem. Any help would be great.

    Brooke

    http://dev.brandondukes.com/wordpress2/signup/

    Posted 13 years ago on Monday January 17, 2011 | Permalink
  2. Sent you an email as well, but posting here for the benefit of other users who might have a similar desire.

    The following code snippet uses to the gform_save_field_value to modify the value of the field immediately before it is saved to the database. This will allow you to override any formatting that Gravity Forms automatically applies to value types such as the phone field.

    http://pastie.org/1469933

    Posted 13 years ago on Monday January 17, 2011 | Permalink
  3. So this works fine on my developement enviroment but as soon as i moved it to production and changed the form ID to the correct ID it stopped working. I'm getting the phone number stored in the (NNN) NNN-NNNN format.

    I don't see anything wrong with this code

    add_filter("gform_save_field_value", "ba_save_phone_value", 9, 4);
    function ba_save_phone_value($value, $lead, $field, $form){
    
        if($form['id'] != 4 || $field['id'] != 3 ){
            return $value;
            }
    
            $value = preg_replace('/\D/', '', $value );
            return $value;
    
    }

    Its weird that it works perfect on one server not on the other. The only difference I can think of is the dev site only has one form.

    Posted 13 years ago on Thursday February 3, 2011 | Permalink
  4. The issue was that I had to update my version of Gravity Forums on my production site.

    Posted 13 years ago on Monday February 7, 2011 | Permalink

This topic has been resolved and has been closed to new replies.