Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8908435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:10:39+00:00 2026-06-15T03:10:39+00:00

I’ve made an extra custom field called esrnumber . I’ve added a onUserBeforeSave() function

  • 0

I’ve made an extra custom field called esrnumber. I’ve added a onUserBeforeSave()function to the php file within the plugin. This is supposed to take the esrnumber from my custom field as well as the name from the registration form, check a database, and return true if they match. Thus allowing the user to register.

The problem is that i can’t seem to get the field values from the form into this php script. Below is my code.

function onUserBeforeSave($user, $isnew, $new){
//sql code removed for example
    $foundesr = false;
    if ($_SERVER['REQUEST_METHOD'] == 'GET' && isset($_GET['esrnumber'])) {
    $test = $_GET['esrnumber'];
    } else if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['esrnumber']))         {
        $test = $_POST['esrnumber'];
    } else {
        $test = "booo";
    }
   if($foundesr == false){
        JError::raiseWarning(1000, JText::_('There is a problem with your ESR number, ' . JRequest::getVar('username') . JRequest::getVar('esrnumber') . JRequest::getVar('jform_username') . $test . 'it does not match that name in our records.'));
        return false;
    }
    return true;
}

As you can see most of that is unnecessary, I’ve just tried several different methods to retrieve the value from the registration form fields, everyone of them returns empty. Where am i going wrong? How can i simply get the values from my form into this method?

Here’s the HTML code Joomla generates for the form (asfaik this is all default stuff)

<div class="registration">
<form id="member-registration" action="/index.php/component/users/?task=registration.register" method="post" class="form-validate">
            <fieldset>
                <legend>User Registration</legend>
                <dl>
                                <dt>
                <span class="spacer"><span class="before"></span><span class="text"><label id="jform_spacer-lbl" class=""><strong class="red">*</strong> Required field</label></span><span class="after"></span></span>                                    </dt>
            <dd>&#160;</dd>
                                            <dt>
                <label id="jform_name-lbl" for="jform_name" class="hasTip required" title="Name::Enter your full name">Name:<span class="star">&#160;*</span></label>                                   </dt>
            <dd><input type="text" name="jform[name]" id="jform_name" value="pirateballoon@gmail.com" class="required" size="30"/></dd>
                                            <dt>
                <label id="jform_username-lbl" for="jform_username" class="hasTip required" title="Username::Enter your desired user name">Username:<span class="star">&#160;*</span></label>                                   </dt>
            <dd><input type="text" name="jform[username]" id="jform_username" value="pirateballoon@gmail.com" class="validate-username required" size="30"/></dd>
                                            <dt>
                <label id="jform_password1-lbl" for="jform_password1" class="hasTip required" title="Password::Enter your desired password - Enter a minimum of 4 characters">Password:<span class="star">&#160;*</span></label>                                    </dt>
            <dd><input type="password" name="jform[password1]" id="jform_password1" value="" autocomplete="off" class="validate-password required" size="30"/></dd>
                                            <dt>
                <label id="jform_password2-lbl" for="jform_password2" class="hasTip required" title="Confirm Password::Confirm your password">Confirm Password:<span class="star">&#160;*</span></label>                                    </dt>
            <dd><input type="password" name="jform[password2]" id="jform_password2" value="" autocomplete="off" class="validate-password required" size="30"/></dd>
                                            <dt>
                <label id="jform_email1-lbl" for="jform_email1" class="hasTip required" title="Email Address::Enter your email address">Email Address:<span class="star">&#160;*</span></label>                                 </dt>
            <dd><input type="text" name="jform[email1]" class="validate-email required" id="jform_email1" value="pirateballoon@gmail.com" size="30"/></dd>
                                            <dt>
                <label id="jform_email2-lbl" for="jform_email2" class="hasTip required" title="Confirm email Address::Confirm your email address">Confirm email Address:<span class="star">&#160;*</span></label>                                   </dt>
            <dd><input type="text" name="jform[email2]" class="validate-email required" id="jform_email2" value="pirateballoon@gmail.com" size="30"/></dd>
                                                                            </dl>
    </fieldset>
                <fieldset>
                <legend>User ESR Profile</legend>
                <dl>
                                <dt>
                <label id="jform_esrprofile_esrnumber-lbl" for="jform_esrprofile_esrnumber" class=" required">ESR Number<span class="star">&#160;*</span></label>                                   </dt>
            <dd><input type="text" name="jform[esrprofile][esrnumber]" id="jform_esrprofile_esrnumber" value="" class="required"/></dd>
                            </dl>
    </fieldset>
        <div>
        <button type="submit" class="validate">Register</button>
        or          <a href="/" title="Cancel">Cancel</a>
        <input type="hidden" name="option" value="com_users" />
        <input type="hidden" name="task" value="registration.register" />
        <input type="hidden" name="b44564159b9c7ebe3b7caf93cc5ce8de" value="1" />       </div>
</form>

I personally never called that new method i made, i just created the method and Joomla seems to automatically call it upon submitting the form.

Cheers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:10:41+00:00Added an answer on June 15, 2026 at 3:10 am

    SOLVED. If anybody finds this thread and needs to know, this is how i did it in the onUserBeforeSave($user, $isnew, $new) function.

    JArrayHelper::getValue($new, 'name', 0, 'STRING')
    

    Gives you your variable. Just change where it says name to get whichever user details you want. To get the ESR number (my custom field) i had to do this:

            foreach ($new['esrprofile'] as $k => $v) {
                 $esrnumber = $v;
            }
    

    There’s probably a more efficient way of getting that esr number out of that array seeing as how i think there’s only one instance of the number in there, but this works for now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have this code to decode numeric html entities to the UTF8 equivalent character.
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.