Registration page

Hi everyone,

I was trying to reduce the registration form to just email adress and password fields but didn't know how to make changes.If anyone can guide me to right direction that will be great. is there already a plugin that allows to change the registration page?

 

Thank You

neupas

  • i apprecciate reply and concerns from everyone.

    @matt thank you for the detailed and excellent instruction.i followed all your instruction and was able to change the the register form through plugin.Now i just have email, password,password2 field in register form.

    I also created folder called 'actions' in customregistration, and copied action file register.php from core. What should i do next to make sure i register the user with just email address and password?

    @DhrupDeScoop i followed matt's instruction and was able make some progress in positive direction.

     

    Looking forward to hear from you

     

    Regards

    neupas

  • @Neupas: Don't feel worried or threatened by any advice - just follow Nudeler's advice blindly -- and when it totally totally screws up your webisite then you can cuss and spit !! But just remember that highly qualified Professionals - who do this for a real $$$living and are not just idly wasting time on parttime hobbies like 'some' others do here -- people such as Matt, Ismayil, etc etc (including myself @ 35++ yerars of experience with Serious Computing Science) and many many other very well educated / heavily experienced Developers here - are all here to help you to (re) build your site back to good standards ;-)

  • @dhrupDeScoop Appreciate your concern. I am looking at everyones comment and appreciate help from them all.

    Can you tell me what changes do i have to make in register.php action file in order to register user with just email address and password?

    Thanks

    neupas

  • @neupas: thats what we told in the begining. Override the form and action. Now add the following code to your start.php

        register_action("my_plugin/my_register",true,elgg_get_plugins_path() . "my_plugin/actions/my_register.php");

    Now copy the original actions/register.php to your mod/my_plugin/actions/my_register.php

    This will register an extra registration action for you.

  • I'm not sure you can create an Elgg account with email address and password alone without providing at least an username additionally. You need to provide at least some unique default name, for example user001, user002 etc. How should Elgg be able to create the account otherwise as there depends a lot on the username. The bundled twitter plugin lets people join with their twitter account, but even this plugin offers people to enter a username optionally. I would need to check the code but I think if people don't provide a name on their own the twitter plugin also creates some kind of default username. You might want to look at the twitter plugin code on your own to see what it does exactly. It might also give you some examples what you need to do with your own custom registration plugin.

  • Hi everyone, this is possible don't worry.  Elgg does require a name and username for the account, but that doesn't mean it has to be specified at registration.  Plus, if the interface is for email login, then the username isn't all that important, and the name can be changed by the user in the settings.  All neupas has to do is set defaults.

    Here's how.

    First of all, you don't actually need to copy the actions/register.php into your plugin.  You can go ahead and delete that.  We're going to use what's called "extending" the action.  Details on that can be found at: http://docs.elgg.org/wiki/Extending_actions (though the example code is out of date)

     

    In the start.php you created, put this code:

    function customregistration_init(){
      elgg_register_plugin_hook_handler('action', 'register', 'customregistration_setdefaults');
    }

    // this function sets defaults for your name/username
    function customregistration_setdefaults(){
      // because your form doesn't have a "name" or "username" field you need to provide defaults

      // generate a unique username - check that it doesn't already exist
      $username = "user1";

      // generate a name - doesn't have to be unique
      // maybe use the first part of the email address eg. matt@gmail.com => "matt"
      $name = "matt";

      set_input('name', $name);
      set_input('username', $username);
    }

    // this triggers your plugin to do its stuff
    register_elgg_event_handler('init', 'system', 'customregistration_init');

     

    Now, you still have to do the legwork for the logic of creating the name/username and it should be pretty self-explanatory as to where that goes, but the basics are there for you.

  • @webgalli, forget those deprecated functions! 

    @neupas, I would suggest the following:

    use elgg_unregister_action() to unregister the default 'register' action

    use elgg_register_action() to reregister the 'register' action providing the new path

    I am not 100% sure, but I think registration form is rendered using elgg_view_form() in which case the action name default to the form name, i.e. action/register = forms/register. The above will make sure you keep the original action name

     

    usernames are required by register_user(), so as suggested by @iionly you will need to assign some default username. 

    elgg_get_entities() with limit = 1 will give you the latest registered user, so you can str_replace whatever namespace you use and add +1 to the digits. perhaps that's not the best way.

    perhaps the easier solution to ensure that user name is unique is to use the email as the base -use base64 or md5 to generate a username. or even better, use microtime(), that will always be unique.

     

  • @II:=  Can be done ;-)
    Just need that Name & UserName patching you refer to.
    Maybe just simple bland defaults e.g. :-
    EMail = 'acbd.efg@gmail.com'
    --> UserName = 'abcdefggmailcom'
    --> Name = 'abcdefg gmailcom'
    Done ;-P

  • @Matt, elegant! One thing is though. Don't forget return true; for your hook handler, otherwise you might prevent the action from being implemented.

  • Combining @Matt's proposal with mine:

    function customregistration_init(){
      elgg_register_plugin_hook_handler('action', 'register', 'customregistration_setdefaults');
    }

    // this function sets defaults for your name/username
    function customregistration_setdefaults(){
      // because your form doesn't have a "name" or "username" field you need to provide defaults

      // generate a unique username - check that it doesn't already exist
      $username = microtime();

      // generate a name - doesn't have to be unique
      // maybe use the first part of the email address eg. matt@gmail.com => "matt"
      $name = explode('@', get_input('email'));

    $name = $name[0];

      set_input('name', $name);
      set_input('username', $username);

    return true;
    }

    // this triggers your plugin to do its stuff
    register_elgg_event_handler('init', 'system', 'customregistration_init');