Registration and custom fields

  • Posts: 1119
  • Thank you received: 114
8 years 11 months ago #224423

Hi,

So i would like to add Last name when user register. Which i need between first name and login name.
I have created custom field with user table but it will display on the bottom so not good. So added this in user/regsitration view file:

<div class="hikashop_registration_surname_line form-group" id="hikashop_registration_surname_line">
    <div class="key col-sm-3 control-label">
			<label for="surname">
				<?php echo JText::_( 'HIKA_USER_SURNAME' ); ?> *
			</label>
		</div>
			<div class="col-sm-9">
				<input type="text" name="data[user][surname]" id="surname" value="<?php echo $this->escape($this->mainUser->get( 'surname' ));?>" class="inputbox required" maxlength="50" />
				
			</div>

It shows correctly but system wont give a message if it is not entered. It also won't synchronize with joomla or hikashop...

Basically what i need is last name field which would be somehow sinchronized with joomla and hikashop address last name as i have created last name there too. How can i have this?

Also if i enter something in default value of custom field it wont show. It seems i am doing something wrong.

I need this because some people when buying enter they last name in login name field...

Thanks

Last edit: 8 years 11 months ago by kyratn.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
8 years 11 months ago #224426

Hi,

I'm not sure what you're trying to do.
You're talking about the Joomla user, the HikaShop user and the HikaShop address.
These are three different things, and if you add a field for one type of data, there is no synchronization with another type (unless you write some custom plugin to handle it).
In the input, you're using the name

data[user][surname]
which means that you want the data entered to be saved in the custom field called "surname" in the table "user". Is that what you want ? Did you really create a custom user field like that ? Then, in the value attribute, you're loading the "surname" field value from the Joomla user, but Joomla doesn't doesn't have such field by default. Did you added it ?

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
8 years 11 months ago #224472

Hi,

I will try to explain it more clearly. I need field in joomla user registration and hikashop user registration called "Surname" I need it to act like default "Name" field. I use joomla registration and in checkout hikashop registration. So if someone register first with joomla registration. Name, login name, password, email are synchronized with hikashop. Or if someone goes to checkout he will be asked to register with hikashop registration and all entered data will be synchronized with joomla user.
So I creaded field in joomla. I added this code to /components/com_users/models/forms/registration.xml:

<field name="surname" type="text"
		        class="inputbox"
			description="COM_USERS_REGISTER_SURNAME_DESC"
			label="COM_USERS_REGISTER_SURNAME_LABEL"
			required="true"
			size="30"
		/>
I added same to administrator..../user.xml file so field is visible in admin panel.
Created in phpmyadmin field with name "surname" type "varchar" in table xxxx_users

Then I created custom field with column name"surname" in user table (Picture attached) and added this code to user/registration view file:
<div class="hikashop_registration_surname_line form-group" id="hikashop_registration_surname_line">
    <div class="key col-sm-3 control-label">
			<label for="surname">
				<?php echo JText::_( 'HIKA_USER_SURNAME' ); ?> *
			</label>
		</div>
			<div class="col-sm-9">
				<input type="text" name="data[user][surname]" id="surname" value="<?php echo $this->escape($this->mainUser->get( 'surname' ));?>" class="inputbox required" maxlength="50" />
				
			</div>

Everything shows correctly but surname field wont synchronize between joomla user and hikashop user like it does with default field "Name". Also if nothing is entered in that field on hikashop registration, system won't give error message that you need to enter surname first to proceed.
Probably I did something wrong or I miss something.
Any help would be appreciated.

Update. So now if user register with joomla registration it gets synchronized with hikashop in hikashop>customers>users
However if registered in checkout with hikashop registration field "surname" won't get synchronized with joomla or hikashop>customers>users
Tried with protostar template and got same...

Regards

Attachments:
Last edit: 8 years 11 months ago by kyratn.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
8 years 11 months ago #224508

Hi,

That's normal. As I said in my previous message, there is no synchronisation between Joomla user data and HikaShop user custom fields.
So if you want one, you need to write a small plugin to do it.
For example, you would create a system plugin for Joomla and implement the onAfterUserCreate trigger of HikaShop so that in there, you could get the custom user field data in $element->my_field (where my_field is the custom user field column name) and then store it in the user entry in the **_users table of Joomla for the current user.

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
8 years 11 months ago #224553

Hi,

I still can't understand.
When i register with joomla registration page it will add surname field to hikashop created custom field. So thats OK.
The only problem is that if registered in checkout with hikashop registration it wont add/save surname field to hikashop user or joomla user. Isnt it hikashop related? Should't plugin be created for hikashop so it would save hikashop user information too?
Then how column called "Name" is synchronized? Maybe i could do same without custom field. As it wont have such field in custom field?

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
8 years 11 months ago #224566

Hi,

HikaShop doesn't have a name field. It has a manual synchronization, which is written in hard in the code to get the data from the name input field and store it in the name field of the Joomla user account.
But since there is no "surname" field normally in Joomla, there is no code to do that manual synchronization.
We can't predict in advance what field you would add and how you would call them.
So that's why I recommended developing a small custom plugin, so that this manual synchronization would be done by the code in the plugin.

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
8 years 11 months ago #224639

Ok, thanks. I just thought maybe I am doing something wrong cause there was no synchronization btw hikashop custom field and hikashop it self.

Will look into plugin.

Thanks

Please Log in or Create an account to join the conversation.

Time to create page: 0.064 seconds
Powered by Kunena Forum