Need help adding an action to registration and user form submit I'm a Drupal frontend developer with limited experience with coding PHP and scripts. I believe the task is fairly simple for a drupal backend developer (hopefully). 

Here is the basics of what we are trying to achieve:
We need to execute a function upon submitting form feilds of user-register-form and the user_profile_form. Both of the functions basically take the field data and send it to our CRM tool. We have tested both of these functions using an HTML based form and can confirm that both work properly. The challenge for me is how to trigger these functions upon existing Drupal forms. 

Here is the example of the script that needs to be triggered for the user-registration-form:

$(document).ready(function () {
            $("#user-register-form #edit-submit").click(function () {
                alert("Hello world");
                //var ulMembers = $('#ulMembers');
                var member = new Object();
                member.name = $("#edit-field-first-name-und-0-value").val();
                member.country = $("#edit-field-country-und").val();
                member.emailId = $("#edit-mail").val();
                member.description = $("#edit-field-description-und-0-value").val();
                member.membershiplevel = $('#edit-field-membership-price-und').val();
                $.ajax({
                    url:
'http://gsplatformapi-test.ap-southeast-1.elasticbeanstalk.com/api/Values',
                    //url: 'http://localhost:54915/api/Values',
                    type: 'POST',
                    dataType: 'json',
                    data: member,
                    success: function (data) {
                        alert(data);
                        $('#successmessage').text('record inserted');
                    },
                    error: function (error) {
                        console.log('Error in Operation');
                    }
                });
            })
        })


Here is the function that needs to be triggered user_profile_form. It is basically the same type of function as the one above, just with more fields:

      $(document).ready(function () {
            $("#user-profile-form #edit-submit").click(function () {
                //var ulMembers = $('#ulMembers');
                var member = new Object();
                //member.name = $("#edit-field-first-name-und-0-value").val();
                member.country = $("#edit-field-country-und").val();
                member.emailid = $("#edit-mail").val();             
                member.website = $("#edit-field-website-und-0-url").val();
                member.description = $("#edit-field-description-und-0-value").val();
                member.membershiplevel = $('#edit-field-membership-price-und').val();
               $.ajax({
                    url:
'http://gsplatformapi-test.ap-southeast-1.elasticbeanstalk.com/api/Values/' +
$('#txtName').val(),
                    type: 'PUT',
                    dataType: 'json',
                    //Accept: '*/*',
                    //Origin: 'http://localhost:64636/',
                    data: member,
                    success: function (data) {
                        //
                        alert(data);
                        $('#successmessage').text('record updated');
                    },

                    error: function (error) {
                        console.log('Error in Operation');
                    }
                });
            }
            )
        }
        )


If anyone can help point me in the right direction I would greatly appreciate it. Thanks very much!
You must implement hook_form_alter, like this:

function MODULENAME_form_alter(&amp;$form, $form_state, $form_id) {
  if ($form_id == 'user_register_form') { 
    $form['#submit'][] = 'name_of_callback_function';
  }
}


NOTE: You can also implement this hook in your theme. Remember to clear the cache.