Take the 2-minute tour ×

is there a way to cleanly override the function "form_execute_handlers(...)" which is found in /includes/form.inc ?

The problem is that there are some handler-functions like "user_profile_form_validate(...)" in /modules/user/user.pages.inc which cannot be found by the core version of "form.inc", since the following statement is missing in "form_execute_handlers(...)" for this special case:

module_load_include('inc', 'user', 'user.pages');

I would like to add that somehow, and therefore override form.inc ;)

Ok, I found a way to include the library (inside my custom module):

function wr_pages_init() {
  if (($_GET['q'] == 'system/ajax' || strstr($_GET['q'], 'file/ajax/')) && $_POST['form_id'] == "user_profile_form") {
share|improve this question
Do not ever override core! ever! why you need to override that (form_execute_handlers)? what you are trying to do? –  Hardy Feb 23 at 17:23
I am working on a one pager site, and therefore I need AJAX-handling of all forms, including the user profile form. However Drupal's AJAX functionality seems to be incomplete. It is easy to handle a regular login with AJAX, but if you try to handle the so-called user-profile-form, you will need to include "user.pages.inc" first, and therefore you have to extend Drupal's functionality. –  sebastian Feb 24 at 11:00
Ok, still no need for overriding anything. Check how i have created user profile form here: stackoverflow.com/questions/21959283/… You can use AJAX in that form if you want. –  Hardy Feb 24 at 11:08

1 Answer 1

up vote 1 down vote accepted

Never change core functionality! Updating drupal will override your changes and is not good practice at all. Keep in mind that all other modules uses core too so things goes really wrong if you mess with core.

You can do custom user form like this (link to other answer):

drupal 7 cusomized user profile template can not save changes

There is also hooks for altering form handling. So you can change user form validation like this:

hook_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'user_profile_form') {
    $form['#validate'][] = 'your_validation_function';

Or if you want only to use your own validation change:

$form['#validate'] = array('your_validation_function');

You don't have to check queries when including user library. Just include it like:

function wr_pages_init() {


  // And other includes (if needed) same way.. like:

  // Add jquery ui libraries..
  drupal_add_library('system', 'ui');
  drupal_add_library('system', 'ui.sortable');
  drupal_add_library('system', 'ui.datepicker');

  // Add ajax..
  drupal_add_library('system', 'drupal.ajax');

  // Some own JS
  drupal_add_js(drupal_get_path('module', 'wr_pages') . '/js/mysuper.js', 'file');

share|improve this answer
What you did makes sense, but I would have to write my own validation function then. I would like to use the one from user.pages.inc, I just posted a workaround, which does the job for me. I hope this way I won't ever run into trouble when things get updated. –  sebastian Feb 24 at 11:27
No, as i show you can add your own valdation function OR replace the existing. Validation functions is array.. so it can have more than one function. –  Hardy Feb 24 at 11:31
Of course in my link example you would create your own validation, but it's not that hard.. you can check how original user form validation work and add your own stuff if need something special. –  Hardy Feb 24 at 11:38
I'm checking the query to make sure, that I won't include the library on every AJAX call, to keep server response time at the minimum. I'm glad I finally got this working. Figuring out why adding $form['actions']['submit']['#ajax'] = ...; to the user_profile_form would lead to HTTP error 500 was a pain, but it was really just the missing library ;) Thank your for your help, your answer clarifies the mechanism, and I am pretty sure, there will be a bunch of cases coming up where I'll have to write my own validation function. –  sebastian Feb 24 at 11:46

Your Answer


