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

  • You have to override the registration page action and the registration page form view. If you know elgg structure, its only a few minutes code. Have a look on the docs.elgg.org for more info on how to start plugin development. There is no plugin available for it yet.

  • Nudeler2

    You could try to delete some code in:

    elgg/views/default/forms/register.php

     

  • Thanks a lot for prompt reply. really appreciate it.

    Do  i also have to edit adduser.php page?

    I commented out few codes in  actions/register.php

    <?php
    /**
     * Elgg registration action
     *
     * @package Elgg.Core
     * @subpackage User.Account
     */

    elgg_make_sticky_form('register');

    // Get variables
    //$username = get_input('username');
    $password = get_input('password');
    $password2 = get_input('password2');
    $email = get_input('email');
    //$name = get_input('name');
    $friend_guid = (int) get_input('friend_guid', 0);
    $invitecode = get_input('invitecode');

    if (elgg_get_config('allow_registration')) {
        try {
            if (trim($password) == "" || trim($password2) == "") {
                throw new RegistrationException(elgg_echo('RegistrationException:EmptyPassword'));
            }

            if (strcmp($password, $password2) != 0) {
                throw new RegistrationException(elgg_echo('RegistrationException:PasswordMismatch'));
            }

            $guid = register_user( $password, $email, false, $friend_guid, $invitecode);

            if ($guid) {
                elgg_clear_sticky_form('register');
               
                $new_user = get_entity($guid);

                // allow plugins to respond to self registration
                // note: To catch all new users, even those created by an admin,
                // register for the create, user event instead.
                // only passing vars that aren't in ElggUser.
                $params = array(
                    'user' => $new_user,
                    'password' => $password,
                    'friend_guid' => $friend_guid,
                    'invitecode' => $invitecode
                );

                // @todo should registration be allowed no matter what the plugins return?
                if (!elgg_trigger_plugin_hook('register', 'user', $params, TRUE)) {
                    $new_user->delete();
                    // @todo this is a generic messages. We could have plugins
                    // throw a RegistrationException, but that is very odd
                    // for the plugin hooks system.
                    throw new RegistrationException(elgg_echo('registerbad'));
                }

                system_message(elgg_echo("registerok", array(elgg_get_site_entity()->name)));

                // if exception thrown, this probably means there is a validation
                // plugin that has disabled the user
                try {
                    login($new_user);
                } catch (LoginException $e) {
                    // do nothing
                }

                // Forward on success, assume everything else is an error...
                forward();
            } else {
                register_error(elgg_echo("registerbad"));
            }
        } catch (RegistrationException $r) {
            register_error($r->getMessage());
        }
    } else {
        register_error(elgg_echo('registerdisabled'));
    }

    forward(REFERER);

     

    and i also commented out few lines in forms/register.php

    I was able to successfully change the layout but when i try to register i am getting this error "Your registration was unsuccessful because of unknown error".

    Looking forward to your reply.

     

    Thanks

    neupas

  • Nudeler2

    I do not know, but I guess username (and possibly name) should not be outcommented. That should makes sense. :)

    I guess there are dependencies to the core?

  • You can change registration form in:

    views/default/forms/register.php  

  • Woah, hold up a sec.

    @Nudeler2, @Liang Lee - Why are you instructing new members to hack the core?  If you can't give good advice please consider staying silent on the matter.

     

    @neupas - Don't listen to them, please.  Their advice can only lead to site breakage, frustration and confusion.  If you are new to Elgg, or frameworks in general, there are some things you should know.

    Elgg is coded in such a way that almost anything can be changed via plugins.  By keeping changes localized to plugins, the "core" code (the code you downloaded and installed initially) can remain unchanged.  This allows patches and upgrades to be applied without breaking your website.  If you change the core code, and then upgrade elgg, all of your changes will be lost.  If you have made extensive changes, it will be extremely hard to remember everything you've done and most likely you'll have to start from scratch.

    This is why Elgg is so powerful.  With exact same core base, different people can make different applications to do different things, all through plugins, and without changing anything in the core code.  Additionally, the core code provides security to your site, and changing the wrong thing in the core could compromise that.

    Now, the correct way of changing the register form is as follows:

    1. Create a folder for your plugin, call it say, "customregistration"

    2. In that folder, create a file called start.php, at this point it can be empty

    3. Copy a manifest.xml file from any other plugin, and place it in your "customregistration" folder

    4. Create folder in "customregistration" called "views", and inside that "default" and inside that "forms"

    5. Create a file in "forms" called "register.php"

    6. Copy the contents of the core register.php to your new register.php

    7. Make your customizations to your new register.php

    8. Install your plugin as you would any other - you now have a customized register.php

     

    Now, depending what you change you may need to overwrite the action that handles the form submission, but we can discuss that when it gets to that point.

  • @Matt: Caeci caecos ducentes ?;)

    @Neupas: There should a few PlugIns around that do similar if not exact features that you are seeking - search for and find those; and also if not already done - try to learn somw stuff about coding with PHP @ http://w3schools.com, http://w3schools.com/php/default.asp. Matt's notes are quite very more than sufficient to get your requirement done. The ' overwrite the action that handles the form submission..' will apply because the actions will need to change to comlement tha input form code changes. Pay some sincere attention and run and code with all that he's said.

  • Nudeler2

    @ Matt Beckett

    Woah, hold up a sec.

    @Nudeler2, @Liang Lee - Why are you instructing new members to hack the core?  If you can't give good advice please consider staying silent on the matter.

    Don' tell lies about me: I did not "instruct" a new member to hack the core.

    Just read again, what I wrote (on his question):

    You could try to delete some code in:

    elgg/views/default/forms/register.php

    That was no "instruction".

    Right is, that the member already hacked in his code.

    So what should I do? Forbid this?

    Dictate him to stay silent on this matter?

    Who am I?

    Not you!

  • That was indeed an instruction.  Just because you used the word "could" doesn't make it any less of an instruction.  Nowhere in his question did he indicate that he had already hacked his core code, and if it did the appropriate response would not be "well try hacking this file as well", it would be the response I posted, which is don't hack the core, use the views overriding functionality that was built for this purpose.

    On one hand I really want to just ignore you and not reply to anything you post, however, I simply can't.  This is a community, with the purpose of helping people to use and learn Elgg.  You are completely undermining that by doling out your horrible, horrible advice at every chance.

    I'm not always right, and when someone posts something that proves me wrong, I correct myself and usually thank that person for showing me the correct way of doing something.  I don't keep fighting with stupid symantic arguments like "I said he could do..."

    So yes, if you don't know the answer, you should keep quiet.  If you think you know the answer and are proven wrong, don't be a jerk about it.  Accept it and let the original poster know that you were in error.