How to modify uservalidationbyadmin in order to send my reg. field by email?

I modified the registration form by:

1 - overriding the default registration form in order to eliminate "name" field and add "something about you" field

2 - overriding the default register action in order to set $name = $username

Now, I don't need to store "something about you" field, but I'd like to receive it in the uservalidationbyadmin e-mail in order to recognize spammers. Is it possible? What have I to change?

  • The account data used within uservalidationbyadmin are taken from the user entity metadata (e.g. name, email). If you want to include the info entered when a new account is registered, you have to save this info also within a metadata field belonging to the user entity. Then you can retrieve the info saved in the metadata field within the code of the uservalidationbyadmin plugin where the notification is sent (with modification of the notification text accordingly). I think the code for notification sending to admin is in uservalidationbyadmin/lib/functions.php (line 76 ff).

  • Thanks! I tried something like what you say, but I didn't succeed... Can you give me a hint?

    I think I have to work on my register.php: I tried the modification highlighted below, but I'm not sure about what I'm doing...



    // Get variables
    $username = get_input('username');
    $password = get_input('password', null, false);
    $password2 = get_input('password2', null, false);
    $email = get_input('email');
    $name = $username; //I don't want a username different from public name
    $friend_guid = (int) get_input('friend_guid', 0);
    $invitecode = get_input('invitecode');

    $aboutme = get_input('aboutme'); //<----------------------------------

    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($username, $password, $name, $email, false, $friend_guid, $invitecode);

    if ($guid) {
    $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,

    'aboutme' => $aboutme //<----------------------------------------------------

    // @todo should registration be allowed no matter what the plugins return?
    if (!elgg_trigger_plugin_hook('register', 'user', $params, TRUE)) {
    $ia = elgg_set_ignore_access(true);
    // @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 {
    } catch (LoginException $e) {
    // do nothing

    // Forward on success, assume everything else is an error...
    } else {
    } catch (RegistrationException $r) {
    } else {





  • I think there's no need to override the register view/ form at all. Instead you could extend the view to add your "about me" input field. As I understand you only want to use this field for account verification purposes (with uservalidationbyadmin plugin) but not add a profile field that shows this info on the profile pages. You can take a look at a plugin of mine ( that adds a checkbox to the register page. This is not exactly the same as you need but you will can see at least how to extend the register form and how to evaluate the input.

    The user input is evaluated in the function agerestriction_register_hook() in my plugin. In the same way you retrieve the "about me" input and save it for example as metadata:

    function about_me_user_input($hook, $type, $value, $params) {

        $user = elgg_extract('user', $params);

        if (!$user instanceof ElggUser) {

        $about_me = get_input('about_me', false);

        if ($about_me) {

            $user->about_me = $about_me;






    This function should be called by the 'action', 'register' plugin hook. Within the uservalidationbyadmin plugin the same plugin hook is used to manage the account validation / notify the admin. The notification is sent in the function uservalidationbyadmin_request_validation() that's in the lib/functions.php file. For the notification your can provide the text of the about_me input with $user->about_me. You only need to give the plugin hook function that retrieves the input in your plugin a higher priority ( to make sure it's executed before the plugin hook callback function in the uservalidationbyadmin plugin to be sure that the about_me input has already been retrieved and saved as metadata. The above code for the callback function might not be perfect yet. You might need to improve it to catch eventual misuse / faults of the users. For the rest that's necessary to extend the register page, you could take my plugin as a starting point and modify what's needed.

  • Thank you very much for your effort in your answer! It's not a piece of cake but I think I can do it.

    At the benigging I tried to simply extend the view, as you suggest, but I did't succeed in making my additional field sticky. May be I'll be more fortunate this time!

  • I just noticed that I have the register form included in the Age Restriction plugin that I linked above. This would override the original core from. I don't think that this is necessary, i.e. it should work (better) when not overriding the core register fom.

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking