I am customizing the user registration in the template file. I want to auto submit the registration form using Drupal code, or JavaScript code.

Does anyone know how I should achieve this?

  • 1
    Click the button says "Create New Account". Its simple. ;) – niksmac Nov 28 '12 at 13:24
  • 1
    Please make sure you add in the research you've already done yourself; what you tried, what didn't work, what errors you received, etc. It isn't appropriate to ask for what essentially would be a full tutorial on a Stack Exchange site :) – Clive Nov 28 '12 at 13:28
  • What do you mean by auto submit ? – GoodSp33d Nov 28 '12 at 13:41
  • i have the fields which is filled with random values in the registration form using java script and i want to submit the form programmatically using any scripts or code. – Dhinesh.ES Nov 28 '12 at 14:00
  • Why do you want to by pass this form? Are you trying to create mock users for testing? If so look at devel generate. – Rick Nov 28 '12 at 16:47

Based on your question, I would recommend you use the devel module to auto-generate random users.

OR if you really want to auto-submit the user form (or any form) then attach JavaScript to the page that does so via #attached in a hook_form_alter or via drupal_add_js() or simply in your theme via a .js file included in your .info file.

The javascript would be as Eugene Fidelin has posted above – $('#user-register-form').submit();or potentially by extending the Drupal.behaviors object, which is recommended for a number of reasons I won't get into here:

(function ($) {

  Drupal.behaviors.myModule = {
    attach: function (context) {


To submit user register form use following code:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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