I'm using joomla 1.7 and I want for some users to not have the option to insert a username.
I'm trying to set that on registration (for said users) the system will save the inputted email in the username field and the email field, and remove the username textbox from the form.
I know i need to insert $data['username'] = $data['email'] somewhere but I cant find the right place.
I tried to put it like this in the registration model under public function register($temp) with no success. I can't find another logical place to put it.
// Prepare the data for the user object.
$data['my_teacher'] = $data['my_teacher'];
$data['email'] = $data['email1'];
$data['username'] = $data['email1'];
$data['password'] = $data['password1'];
$useractivation = $params->get('useractivation');
i found a way to do this
just add
if(isset($temp['email1'])){
$temp['username'] = $temp['email1'];
}
right under
$temp = (array)$app->getUserState('com_users.registration.data', array());
in the module file and then remove the "username" fiels from the .xml and add a hidden field named:jform[username] and id:jform_username in the default.php file in the views/registration/tmpl
the line looks like this
<input type="text" name="jform[username]" id="jform_username" value="<?php echo 'something.random.that.will.be.replaced.with.the.email'; ?>" style="visibility:hidden;">
all the files that i am talking about are under /components/com_users/
it should work...
http://extensions.joomla.org/extensions/access-a-security/authentication/10343
The above extension will remove the need for users to enter a username on registration. However it generates a username based on the name field. It uses the email address as the username only as a last resort, because this can cause problems with certain extensions in Joomla. It also allows users to login with their email address.
Dylan
Related
Note: email address structure is local-part#domain.
For example I am asking user to provide his email:
<label>Your Gmail:</label><input type="email" name="emailaddress"><label>#gmail.com</label>
But instead of letting him/her type the complete email address (e.g. user#gmail.com), I want to let user type only local-part without domain. But how can I send this email to MySql database now? Basically I need to append custom input to #gmail.com every time user submits the form. For example, records in my database would look like user1#gmail.com, user2#gmail.com etc.
Can anyone help?
In PHP build a String like this.
$email = $_REQUEST['emailaddress'];
echo "$email#gmail.com";
if the value submitted by the form was john.smith, the output would be
john.smith#gmail.com
Read PHP 5 Form Handling to understand how to retrieve the parameters parsed by the form.
Tried in my local works perfect.
$email = $_POST['email'] //Text box value
$email = $email."#gmail.com";
You are required to do some concatenation like above
in ProcessWire admin you're only able to log in using your name (username) but as I'm using e-mail log in in front end I want to use e-mail for backend, too.
How can I change admin login form to allow e-mail-address?
Here is the solution I came up with
I placed those hooks in my site/init.php file
// change login name input label to e-mail-address
$wire->addHookAfter('ProcessLogin::buildLoginForm', function(HookEvent $event) {
// on liner as we don't change anything else
$event->return->get('login_name')->set('label', $event->_('E-Mail-Address'));
});
// hook into session::login to get user by mail
$wire->addHookBefore('Session::login', function(HookEvent $event) {
// need to get email from $input as processLogin::execute is pageName sanitizing
$email = $event->input->post->email('login_name');
// stop here if login_name not a valid email
if (!$email) return;
// new selector arrays don't seem to work on $user so using $pages here
$user = $event->pages->get([['email', $email]]);
// if valid user set login name argument
if ($user->id) $event->setArgument('name', $user->name);
});
bare in mind that e-mail is not a unique field so if you don't ensure uniqueness of e-mail addresses this won't work, you could change it a little to overcome this though..
Have a look at https://processwire.com/talk/topic/1838-login-using-e-mail-rather-than-username-and-general-login-issues/ where Ryan posts some more infos about this and possible solutions in case of duplicate e-mail addresses
and https://processwire.com/talk/topic/1716-integrating-a-member-visitor-login-form/ for more on front-end login strategies
How can I retrieve an array of email addresses from MediaWiki in php?
The reason is that I want to modify the BlockAndNuke extension so that it shows the user's email address, and not just the username, at the special page Special:BlockAndNuke.
The method is called $user->getEmail();. Where you get the user object from, depends on how the extensions looks. If you intend to modify special page of the BlockAndNuke extension, you would end up with something like
/* First create a user object for this user name */
$user = User::newFromName( $name );
/* Then ask for the users email address*/
$emailAddress = $user->getEmail();
You can also create a User object from an id: $user = User::newFromId( $id )
I am using the Joomla! component Fabrik.
The functionality I am trying to get is to have users buy a unique code from my website using e-junkie. On completion of payment, e-junkie will process a script that will send the code to a MySQL database table.
After buying, they will then be redirected to a page on the website to activate their code by filling in a form. In order to activate their code, they will need to enter data into three text fields:
First Name
Last Name
Unique Code
The form is already set up with Fabrik and displayed nicely on the website.
What I need now is when the form is submitted, I need it to connect to the database where the unique codes are stored, search the database table for the matching firstname,lastname and unique code and return a success message if a match is found and a failure message if no match is found.
Fabrik allows for PHP plugin scripts to run when the form is submitted, I will use a separate plugin for each field on the form.
So far I have come up with the snippet of code below which would be executed when the form is submitted. I am just attempting to validate the firstname field on the form at this stage just to get it working. once it is working i will duplicate the code and adapt it for the other fields (e.g lastname and uniquecode).
Problem is i just cant get it to work. It uses Joomla's JFactory/getDBO to connect to the database.
My Table name is travelcodes
The fields on the form are, firstname, lastname and uniquecode
the columns on the table are also firstname,lastname and uniquecode
$firstname = '{travelcodes___firstname}';
$value = '{tablename___firstname}';
$db =JFactory::getDBO();
$query=("SELECT firstname FROM travelcodes where field = '$firstname'");
$db->setQuery($query);
$response = $db->loadResult();
if ($response == $firstname) {
return true;
} else {
return false;
}
Any help with this would be much appreciated.
Thanks.
Bailey
I have no problem using the following setting
I think you will need to add JRequest::getVar before ('you_element') and have the setting to be onBeforeProcess
$db = JFactory::getDbo();
$date = date("Y-m-d H:i:s", time());
$value = JRequest::getVar('off_line_ap___offline_reason');
$user =& JFactory::getUser();
$uid = $user->id;
$db->setQuery("INSERT INTO d2_exchange_log (date_time, part, quantity, user_id, purpose) VALUES ('{$date}', '{$value}', '99','{$uid}', 'Test')");
$submissionsNo=$db->loadResult();
I am using the EZ Publish CMS:
What is currently happening:
From the forgot password page, user enters the email address that they
used to register and submits
User receives an email with a password generating link which
uses a hash to confirm their identity.
User receives an email with a freshly generated password
User returns to site using the link from their email which takes them
to a form that asks for the old password (which was just generated
and has been sent to their email) and for them to enter a new
password.
What I want to happen:
From the "forgot password" page, user enters the email address that they
used to register and submits
User receives an email with a link to the "enter new password" form
On the "enter new password" form, user is not required to enter old
password because identity has already been confirmed by hash and
therefore only has to enter the new password.
I am using the EZMBPAEX extension which has the original 4 step process.
There doesn't seem to be any documentation or discussion about removing the "email the user a new password" step but my client has a very strict no passwords sent by email policy so I can't flex on this.
Does anyone know where I can find documentation on how to edit this functionality?
I think the file that will need to be edited is located in:
/extension/ezmbpaex/modules/userpaex/forgotpassword.php
First of All create a function to generate a random string for you, let's say you need to create a random string of 32 caracters, choose any number of caracters you want
Function to generate random code which will be sent by email and added to db
function genRandomString() {
$length = 32;
$characters = "0123456789abcdefghijklmnopqrstuvwxyz";
$string ="";
for ($p = 0; $p < $length; $p++) {
$string .= $characters[mt_rand(0, (strlen($characters))-1)];
}
return $string;
}
Next, create a new table using php myAdmin, a table names forgotten_passes which contain three columns, let's say you already did that
$key = genRandomString(); // assign random code
$assign = $db->query("INSERT INTO `YOUR_DB_NAME`.`forgotten_pass` (`email` ,`randomKey` , `time`)
VALUES ('$email', '$key', CURRENT_TIMESTAMP );");
Next send an email which contain a link to your resetpassword.php page ( the page where user asked to choose a new password and confirm it, but do not forget to assign the generated key to a get variable , that's easy, just when you the link
www.yourdomain.com/pass_reset.php ( ADD ?secretkey=THE_GENERATED_HERE )
so the link sent to the email adresse of the person who need to reset the password should contain something like :
Hello username, to reset your password click on the link below or copy/past it into your browser
The link : http://www.yourdomain.com/pass_reset.php?secretKey=a12s236d5c8d4fkejus10a1s2d4c8741
When user click on the link, he will go to a page which verify his email and its corresponding random key in sql database, if it found that there are really an email and that random kay, then the user is really confirmed it's email, so this page should contain something like below :
<?php
if (isset($_GET['secretKey'])) {
$secretKey = $_GET['secretKey'];
// Check wether it really exist in database
$sql = 'select * from forgotten_pass WHERE email=$The_User_Email and randomKey='$secretKey'';
}
Now, just count the number of rows to see if there are returned data, if there are returned data than the user really connected to its inbox and clicked the link.
Just do the following :
if mysql_num_rows($sql)>0 { echo "Success, ";
?>
// in this part type the html code which displays two inputs text, password
// and confirm password that connect to database and update the user's password
<form method="post" action="passupdate.php">
<input name="password" value =""/>
<input name"confirmedPassword" value=""/>
<input type="submit" value="Save my new password">
</form>
<?php
} else {
echo "Sorry, invalid reset link";
}
When I updated the plugin it had the number of steps I wanted.