Jump to content
Tung at RockPOS.com

Log-in with username instead of email - Module attached

Recommended Posts

Very nice module, good idea and thanks for sharing.

 

But have to ask what is happening in registration process, does user enter both username and email ?

And I do not see in code where username is saved.

Share this post


Link to post
Share on other sites

Good question! This is originally for the guy in this topic Login with username instead of email

Anyway, I've added a new feature and now it supports registration form.

 

Here is how it looks like now:

6404383e-649a-11e4-90f0-465b1702f1ce.png

You will be noticed that, the field username is at the bottom of the form. It does not sound good. But I don't want to manually override the template. If someone wants to move the field to the top, it would be easy to do.

 

I will release the official version very soon.

Tung

  • Like 2

Share this post


Link to post
Share on other sites

how it will work when someone will use for example, email address that already exists in db ?

Share this post


Link to post
Share on other sites

Hi TungCEO

Brilliant module - just what i need! Makes my daily work much easier :)

A couple of things:

  1. I handle/creat most of my clients from back office and would like the Username option there as well in the customer registration form
  2. Username should be visible in front office and back office customer details (read only in FO and read/write if possible in BO)
  3. Search in BO should searh on username as well

Is this possible?

Best regards
Jacob

Share this post


Link to post
Share on other sites

Hi Tung

Thanks for your reply.

I just tested the BO manual create user and in fact it's not even possible to create a manual new user having the modul installed. An error occurs: 
 

 

 

Property Customer->username is empty

 
So basically you can not use the module if you want to manually create a new customer (I do that 5-10 times every day)

I'll post the issues right away.

Thanks
 

Share this post


Link to post
Share on other sites

I added modules override for AdminCustomerController.php so  it saves username on form in back office and also show username in list, so customer can be searched by it.

 

 

hslogginusername.zip

  • Like 1

Share this post


Link to post
Share on other sites

- Adding username works perfectly

- Username shows in customers table

Add new order from Back Office needs to search on Username as well (I am adding yhis to Github)

Great work so far razaro!!

Edited by MrCobbe (see edit history)

Share this post


Link to post
Share on other sites

OK opened Pull request, with 2 changes.

 

Added code so customer can be searched by username when creating new order from BO.

 

Wanted also to override admin/themes/default/template/controllers/orders/form.tpl file, with small change to add username next to searched customer, but could not find a way from module install.

Share this post


Link to post
Share on other sites

Thanks Razaro. I did review your PR and merged it already.

 

Yes, there is no way (if I'm true :) ) to automatically override a template in theme.

 

But here is the good approach:

- Override AdminOrderControler::renderForm()

- At the end of this function

Instead of:

$this->content .= $this->createTemplate('form.tpl')->fetch();

Change to:

$tpl_path = _PS_MODULE_DIR_ .'hslogginusername/views/templates/orders/form.tpl';
$this->content .= $this->context->smarty->createTemplate($tpl_path, $this->context->smarty);

- And of course, put your template here: slogginusername/views/templates/orders/form.tpl

 

Could you please try it?

 

@MrCobbe: simply go here and download it:

https://github.com/prtung8888/hslogginusername/

  • Like 1

Share this post


Link to post
Share on other sites

Hello all

 

For some reason everthing was gone after my upgrade to PrestaShop™ 1.6.0.11

I tried to delete the module and reinstall the one from https://github.com/prtung8888/hslogginusername/ 

Is that the most recent version with all the addition from before Christmas?

When I install it ex. the form field in the manual user creation is gone and the username in the customer list is gone.

Also are there anyone who can implement the changes I requested on GitHub? (search on username i BO):
https://github.com/prtung8888/hslogginusername/issues

Share this post


Link to post
Share on other sites

Can it be installed on version 1.6.0.11?

Because i don't see the module appear in the module section

 

Best regards,

 

Sjoerd

 

It has been installed -  I have used the wrong zip file to install the module. (several are dropped on this forum)

 

example: hslogginusername-master.zip (don't work)

 

I have used the hslogginusername-1.1.zip and it installed without any problem..

 

The only problem i have is that username is not visible in the BO

Edited by Shurek (see edit history)

Share this post


Link to post
Share on other sites

pleas make login with mobilephone number

Share this post


Link to post
Share on other sites

pleas make login with mobilephone number

This field username can also be used as a number, I have checked it and it also works. 

 

Change nothing but instead enter a username, enter 0612345678 in the column username in the table ps_customer in the database. And you can login with mobilephone number

  • Like 1

Share this post


Link to post
Share on other sites

Can it be installed on version 1.6.0.11?

Because i don't see the module appear in the module section

 

Best regards,

 

Sjoerd

 

It has been installed -  I have used the wrong zip file to install the module. (several are dropped on this forum)

 

example: hslogginusername-master.zip (don't work)

 

I have used the hslogginusername-1.1.zip and it installed without any problem..

 

The only problem i have is that username is not visible in the BO

Hi,

 

I have the same problem than Shurek  in version 1.6.0.11 : BO tells me the module was uploaded, but it doesn't appear in the module list and I can't see it anywhere in FTP files either.

He's right, everything works fine for the uploading part with hslogginusername-1.1.zip instead of the hslogginusername-master.zip.
 
But then I have an error message when installing the module: "Le ou les modules suivants n'ont pas été correctement installés : hslogginusername :  Impossible d'installer la surcharge : La méthode __construct dans la classe Customer est déjà surchargée."
Which could be translated in English as :"The module could not be installed correctly : hslogginusername : Impossible to install the overload : Method _construct in table Customer is already overloaded.
 
Any clue?
 
Thanks a lot anyway for this module, which is exactly what I'm looking for.

Share this post


Link to post
Share on other sites

Any clue ?

 

Well it says " Method _construct in table Customer is already overloaded."

W

 

So that means you already have some module that overrides customer class and construct method in that class.

 

You can solve that in different ways, one is to rename override/classes/Customer.php to _Customer.php before installing a module.

Then you would have no problem installing it. But to make other module work you need to merge code from _Customer.php with one

Module installs.

 

So from 

	public function __construct($id = null)
	{
		$this->id_default_group = (int)Configuration::get('PS_CUSTOMER_GROUP');
		self::$definition['fields']['username'] = array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 32);
		parent::__construct($id);
	}

Make sure  merged code have these lines

		$this->id_default_group = (int)Configuration::get('PS_CUSTOMER_GROUP');
		self::$definition['fields']['username'] = array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 32);
		parent::__construct($id);

and make sure you do not have 2 same lines with

parent::__construct($id);

from other modules code. (just guessing)

Share this post


Link to post
Share on other sites

Does not work very well with 1.6, while the username entry does appear at bottom of account creation, when you use this to login you get red X as if username is not acceptable.

However if you proceed anyway you can login, issue is that most customers would not try this and just think that username is wrong.

Username does not appear in customer entry in back office, I tried adding the AdminCustomerController.php override added by razaro but still did not appear in BO.

 

So for me this is not acceptable at this time.

 

 

post-310220-0-21295600-1430950346_thumb.jpg

 

post-310220-0-15705900-1430950354_thumb.jpg

Share this post


Link to post
Share on other sites

Hello there,

If someone finds out any issue, please report here:

https://github.com/prtung8888/hslogginusername/issues

 

I will arrange my time to fix some of them this month. Then, of course, 1 by 1, to clean the list, as I'm quite busy at the moment.

If you have any trouble, I will be to help you out. Send me a private message including the access to your back office + FTP, I will look at that for you.

Rest assured, we won't touch anything else than the module itself.

 

Cheers,

Tung

  • Like 1

Share this post


Link to post
Share on other sites

Hi there,
 
Thanks razaro for pointing me in the right direction and such a precise answer (I already had a public function __construct in the Customer.php override, because of another module).

 

I agree with tdr170 on this point, pretty annoying. Trick it with CSS files is an option, but a little bit messy.

 

Does not work very well with 1.6, while the username entry does appear at bottom of account creation, when you use this to login you get red X as if username is not acceptable.
However if you proceed anyway you can login, issue is that most customers would not try this and just think that username is wrong.
Username does not appear in customer entry in back office, I tried adding the AdminCustomerController.php override added by razaro but still did not appear in BO.

 
Maybe I have a clue on the origin of the problem with "module being uploaded correctly says Prestashop" although nothing shows up : couldn't it be related with the compression software used to create the ZIP file, which may not somehow be "Prestashop-compliant" ? I've made some adjustements to the working module hslogginusername-1.1.zip, recompressed in with Mac compressing utility, and reuploaded it with no success. Tried again compressing the same folder with Winzip on PC : works like a charm.

I also renamed the folder "from "hslogginusername-master" to "hslogginusername" to match .php filename as told Prestashop advices for creating a module.
I'm not sure if it's of any use, but please don't throw stones at me if what I say sounds stupid, I'm not a developer and my abilities are limited to google/read/copy/paste/modify/test :huh2: .
 
I also would like the "Username" field to appear in the logged customer main information so the client can modify it like the email for example (not adding an extra-section in the account). How can I do so?
 
I've created a new hook (displayCustomerIdentity) and a new override/views/templates/front/display_customer_identity.tpl file for front-office to display under the main identity.tpl information..
But obviously I need something more to tell Prestashop where to display it. In an override IdentityController.php I guess?

 

I've posted my questions on github issues.

 

Thanks in advance !

Share this post


Link to post
Share on other sites

Thanks Tung.

 

Meanwhile, if anyone has a clue at least to point me in the right direction, that would be great.

 

 

I badly need this, and if not possible within the next few days, I'll have to communicate to all the users of the previous shop (migrating 15 years of history) that connection with username is not possible anymore, it will be by email.

I will do it, if no other option, but it's pissing me off as I think we are so close to reach perfection on this module.

 

Share this post


Link to post
Share on other sites

Hello,

I've tried with the latest version + fresh copy of PS, it appears to work for me.

 

If you can not install, please check:

- If there are already these files under override/ folder:

/override/classes/Customers.php

/override/controllers/admin/AdminCustomersControllers.php

 

- If your Mysql user has permission to alter table.

...

 

Hope that helps!

Tung

Share this post


Link to post
Share on other sites

Hello,

 

Yes, there both these files in the override, due previous installation of third party modules...

 

I don't mind modifying myself these files to integrate your module's needs, but I still need it to install properly to do so...

Share this post


Link to post
Share on other sites

Does not work very well with 1.6, while the username entry does appear at bottom of account creation, when you use this to login you get red X as if username is not acceptable.

However if you proceed anyway you can login, issue is that most customers would not try this and just think that username is wrong.

Username does not appear in customer entry in back office, I tried adding the AdminCustomerController.php override added by razaro but still did not appear in BO.

 

So for me this is not acceptable at this time.

 

 

attachicon.gifImage1.jpg

 

attachicon.gifImage2.jpg

 

I have the same problem the registration process is ok and the Username is stored in the database. But when I tried to login with the Username instead of an Email, Prestashop gives me an alert because he is specting an email address no a Username.

 

Any ideas to solve this issue ?

Share this post


Link to post
Share on other sites

I wish someone would create module to allow (when ps in maint mode), access via bo email/pwd instead of IP...ave maria pues...just saying lol

Share this post


Link to post
Share on other sites

Everybody,

Please report all issues you have regarding this module on Github:

https://github.com/prtung8888/hslogginusername/issues

 

If you're interested, make a Pull Request, I will review and merge it.

 

I'm really busy, and can't guarantee that all of them will be fixed on time.

But if everyone comes and joins coding stuff, that would be awesome.

 

Thanks!

Tung

Share this post


Link to post
Share on other sites

Hi,

 

This module is very useful, thanks.

 

I'd like to translate the label " Username * " in the account registration form. Is it possible? How?

 

I also would like to move the whole field to the top, but I'm afraid it is impossible...

 

Thanks for your answers!

 

Bye

 

Prestashop 1.6.1.4

Edited by modellling (see edit history)

Share this post


Link to post
Share on other sites

Hi,

 

as some users said before in the latest P.S. Version the module does not work. I have tested it on 1.6.1.13
maybe the developr would take a look

Share this post


Link to post
Share on other sites

Hi there, i have this one https://github.com/prtung8888/hslogginusername -master.zip running ok in 1.6.1.5

Anyway ive been made some modifications for a fine working, hope it helps someone..

 

downloaded from ftp 3 files when installed ../override/controllers/Authcontroller.php also ..themes/mytheme/authentication.tpl and ../themes/mytheme/css/global.css

 

First step open authentication.tpl

around line 80

 

<div class="form-group">

ive added something to class

 

<div class="form-group1">

next line you can change 

 

{l s='Email'}

for something like

 

{l s='Nickname or email'}

Next line change and erase

 

type="email" data-validate"isEmail"

leave it like this

 

type="text"

 

Second step in global.css around line 2475 you can find

 

.form-group {
  margin-bottom: 15px;
}

just after added

 

.form-group1 {

  margin-bottom: 15px;
  padding-right: 30px;
}

 

Save both and upload to respective folder again, now im able to do login without see red border meaning form error.

Edited by Aumanz (see edit history)

Share this post


Link to post
Share on other sites

Also if you like to send this username through the emails to the customer, you have to modify mail templates adding

 

User / Nickname: {username}

anywhere do you like to show it up.

And last step open AuthController.php find

 

return Mail::Send(
$this->context->language->id,
'account',
Mail::l('Welcome!'),
array(
'{firstname}' => $customer->firstname,

 

'{lastname}' => $customer->lastname,

and add inside the array(

 

 

'{username}' => $customer->username,

save, upload, refresh, erase cookies, deactivate cache, try it, comment if dont work for you..

 

Sorry about my english and the poor explanation. Thanks for module!

Edited by Aumanz (see edit history)

Share this post


Link to post
Share on other sites

Anyone can help me to show this username at the top when customer is logged on?

 

im trying to change blockuserinfo.tpl and nav.tpl on themes/mytheme/modules/blocuserinfo adding 

<span value="{if isset($smarty.post.username)}{$smarty.post.username}{/if}">{if isset($smarty.post.username)}{$smarty.post.username}{/if}</span>

and trying also 

{$cookie->username} {$cookie->email} 

email is showed and works fine in all pages. But only showed username on page for change personal information of the customer.

 

Can anyone help me on this? Thanks, regards.

Edited by Aumanz (see edit history)

Share this post


Link to post
Share on other sites

Done :)

 

i've added username to cookie when authentication in AuthController.php

$this->context->cookie->customer_username = $customer->username;

Then im able to call username in nav.tpl

{$cookie->customer_username}

Regards.

Share this post


Link to post
Share on other sites

Hi, I installed this module v 1.1 in ps 1.6.1.15 and working very good. Thanks for the module. 

Share this post


Link to post
Share on other sites

Hi, after installing and using, I faced two errors.

1. Unable to visit MY PERSONAL INFORMATION section of old customers ( registered before module installation )

2. Unable to IMPORT CUSTOMERS through CSV. ( It is showing error like, Customer->username is empty )

 

I resolved second issue, by adding following lines in /path-to-prestashop/controllers/admin/AdminImportController.php

( after line 330, i.e after passwd add this )-->      'username' => array('label' => $this->l('Username *')),  

modify line  322 -->   

$this->required_fields = array('email', 'passwd', 'lastname', 'firstname');    -------->   $this->required_fields = array('email', 'passwd', 'lastname', 'username', 'firstname');

 

Share this post


Link to post
Share on other sites
On 12/11/2017 at 2:09 PM, rahulteja said:

Hi, after installing and using, I faced two errors.

2. Unable to IMPORT CUSTOMERS through CSV. ( It is showing error like,

 

YOU TOO!!!!

Share this post


Link to post
Share on other sites

username?  i suppose for some types of cms's, like a forum this makes sense.

 

however, now you have big issue, if they forget their username....can they put in their email address to 1) get username? and 2) reset password.

 

usernames in ecommerce (really all cms's) IMHO is silly...and will lead to failure...

Share this post


Link to post
Share on other sites

Hi

What should we do to don't forced customers to signing up by option email?

and force option of email, be an optional option.

Thank you

Share this post


Link to post
Share on other sites
On 2/26/2018 at 3:20 AM, El Patron said:

username?  i suppose for some types of cms's, like a forum this makes sense.

 

however, now you have big issue, if they forget their username....can they put in their email address to 1) get username? and 2) reset password.

 

usernames in ecommerce (really all cms's) IMHO is silly...and will lead to failure...

i am new to prestashop but not new to other opensource system like osc.. I have the same concern as you.. I am trying to find a way to have the email available to when username is forgotten. I think the concern the developer had is the ease of login with a username rather than an email.. that makes sense to do it..

 

Edited by tech2crave (see edit history)

Share this post


Link to post
Share on other sites

I have not heard from the original creator of this module for sometime now.. anyone has resolved the issue yet?

Share this post


Link to post
Share on other sites

Hi thank you so much i will use it in my shop 

can anyone say what is best manual after install moduls?(change codes or ect)

Share this post


Link to post
Share on other sites

Any idea how to perform this in prestashop 1.7 ? 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More