Adding Fields to the Registration Page

I'm trying to add registration fields to the account/register page and I eventually would like to access these fields from a modified profile plugin and other plugins. I see how I can override the action and view associated with user registration but the action calls a function register_user() to actually complete the registration. It looks like this function is defined in engine/lib/users.php. I'm not sure if I should be editing users.php. What is the cleanest, most logical way for me to do this?

  • Am I reading between the lines correctly...are you saying you're just here to solicit work for yourself and can't tell me which file this one line of code goes in?

    I'm sure there was a point where you didn't have "knowledge of Elgg internals" and someone had to help you out.

    I know I can create a new subtype called "user_credits" and add metadata to that where the User GUID is the owner, but that just seems like a waste of time if it's possible to add the "credits" metadata directly to the user entity.

  • @Kane

    Have a sense of humor ;-) people who know me differently say different things... just ask around... No.. I am *not ".. just here to solicit work" between the line.. I am actually turning down projects because i do not have the time... Tho I do sometimes get solicitations to do paid work and many times i get solicitations do heavy hours of work for free from people I do not know ;-)


    I do spend up to 30 - 40% of my time not grabbing money but helping fellow ellgsters for $0 and those people show decorum and do not accuse me of soliciting work...;-) There *was a time when i had zero knowledge of elgg... but i never asked *anyone for help, i just read the code to see what was that and where. And I *can tell me exactly how to do the metadata thingy..

    Register.php is definately the right spot ;-( and it does not work for you.. you have coded something wrongly.

    Here is  snippet of code for saving metadata captured at register time from the register form :=

    if ( $membertype==0  )  /** the custom register fieled */
      forward(); // Forward on success, assume everything else is an error...
     //$_SESSION['DPAYmemberType'] = $membertype;
     forward("                    system_message(sprintf(elgg_echo("registerok"),$CONFIG->sitename));
                        if ( $membertype==0  )
                            forward(); // Forward on success, assume everything else is an error...
                            //$_SESSION['DPAYmemberType'] = $membertype;
                            forward("gateway/DPAY_paypal_index.php?LVL=$membertype"); // PayPal Payment Gateway
    ); // PayPal Payment Gateway

    I am not posting the code from "gateway/DPAY_paypal_index.php?LVL=$membertype" here.

    If you want an easy solution, donate  $10 to some charity of your choice and send proof - then I will email you my code. Someone else some months ago.. donated $40 for charity for some custom code help :-



    If you have had a good read thru all all of this... it's your call where you stand.

  • Hi Dhrup,

    I'm sorry if I misinterpreted your post.  You know how frustrating learning a new framework can be, and when I read this thread it just seemed like you were all "I know the answer but I'm not telling you". ;)

    I have more of a "learn by examples" learning style.  I've never been able to sit down and just read code (that's commented poorly) to figure out how things work.  But I don't want to pay someone to do anything for me, I really want to learn Elgg.  It just hasn't been a cakewalk because certain things don't work like they're documented to do, and the documentation is pretty weak and has errors.

    I plan on submitting all my Plugins to the community so hopefully they will be helpful for future folks starting out.

    Unfortunately I have zero income now so charities are not on my to-do list.

    Thanks for your help and again I apologize for snapping at you.

  • LOL ;-)

    aha.. i do sometimes do that act " i know the answer but i ain't telling you..." mostly when lighweight elgg people talk like heavyweights.. cheeses me off...

    elgg code is not quite commented poorly.. if you take time to read the stuff... you will be glad..

    if you go to my galaxy ;-)  and look up Elgg Documentation for Idiots and Experts Alike  you might be surprised by what's avaiable

    if you're having problems... post your code here - then others can give better suggestion ;-)

    did you send your $10 charity donation off yet ?? ;-O LOL. sometimes when people send me $ donations when i help them with code and depending on my mood, i either keep it or.. give to charity.

  • I found this "Site Access Demo" plugin quite helpful.

    Here's what I did to add the "credits" metadata to a user entity upon registering.  I modified an existing plugin I was working on.


    Inside my init function, I added:

    register_elgg_event_handler('create', 'user', 'creds_create_user');

    Then I added this new function:

        function creds_create_user($event, $object_type, $object)
            if (($object) && ($object instanceof ElggUser))
                $creds = 33;
                create_metadata($object->guid, 'creds', $creds,'', 0, ACCESS_PUBLIC);

    I never had any luck just straight modifying the Register.php core action file.  I'm not sure why.  But this method sounds like it's probably a better design anyway.

  • cool... it is a more proper way to do it ;-)

    you don't need too much help any more ;-)

  • Many thanks to Kane!!! Your codes work PERFECTLY for me!!! Thank thank thankssss!!!image

  • how to add also a pulldown menu in the registration form to select their year graduate coz i developing a alumni project using elgg. plz. help me