Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

[SOLVED] Changing from Single Name field to First/Last Name Fields

  • cegarrett
  • cegarrett
  • OFFLINE
  • Posts: 22
  • Thanks: 1
  • Karma: 0
11 years 4 months ago - 11 years 4 months ago #228698 by cegarrett
I setup my community builder site using the Single Name option and now want to change it to to use First & Last Name Fields.

Are there any pitfalls I need to worry about?
My site used CBsubs and I have paid memberships and don't want to cause problems with the customers.

www.joomlapolis.com/forum/112-cb-122-general-discussion/138921-solved-qsingleq-name-to-qfirst-and-lastq-name

I found this Link thru google but it's for an older version of CB. can i follow these directions or do they need to be updated?
Last edit: 11 years 4 months ago by krileon.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48464
  • Thanks: 8280
  • Karma: 1443
11 years 4 months ago #228714 by krileon
I believe CB populates the firstname and lastname fields regardless of your display setting so it should be fine. If it doesn't then your users will need to edit their profile and adjust the firstname and lastname fields as needed or you could run a database query to split it and populate firstname and lastname fields for everyone automatically.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

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

  • cegarrett
  • cegarrett
  • OFFLINE
  • Posts: 22
  • Thanks: 1
  • Karma: 0
11 years 4 months ago - 11 years 4 months ago #228726 by cegarrett
Looking in my Database I only have 6 (of 204) users with First and Last Names Stored (the rest are null).

This Select looks good when I run it but I don't know how to update off of it.

Code:
SELECT TRIM( SUBSTRING_INDEX( `name`, ' ', 1 ) ) AS 'first_name', TRIM( REPLACE( REPLACE( `name`, SUBSTRING_INDEX( `name`, ' ', 1 ), '' ), SUBSTRING_INDEX( `name`, ' ', -1 ), '' ) ) AS 'middle_name', TRIM( SUBSTRING_INDEX( `name`, ' ', -1 ) ) AS 'last_name' FROM `jos_users`
Last edit: 11 years 4 months ago by krileon.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48464
  • Thanks: 8280
  • Karma: 1443
11 years 4 months ago #228728 by krileon
The below will probably do the trick. Note you should make a backup of your database before doing this as I did not test the query.
Code:
UPDATE `jos_comprofiler` AS c SET `firstname` = ( SELECT TRIM( SUBSTRING_INDEX( `name`, ' ', 1 ) ) FROM `jos_users` WHERE `id` = c.`id` ), `middle_name` = ( TRIM( REPLACE( REPLACE( `name`, SUBSTRING_INDEX( `name`, ' ', 1 ), '' ), SUBSTRING_INDEX( `name`, ' ', -1 ), '' ) ) FROM `jos_users` WHERE `id` = c.`id` ), `last_name` = ( SELECT TRIM( SUBSTRING_INDEX( `name`, ' ', -1 ) ) FROM `jos_users` WHERE `id` = c.`id` )


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

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

  • cegarrett
  • cegarrett
  • OFFLINE
  • Posts: 22
  • Thanks: 1
  • Karma: 0
11 years 4 months ago - 11 years 4 months ago #228731 by cegarrett
I ended up using
Code:
UPDATE `jos_comprofiler` AS cb LEFT JOIN `jos_users` AS j ON j.`id` = cb.`user_id` SET cb.`firstname` = TRIM( SUBSTRING_INDEX( j.`name`, ' ', 1 ) ), cb.`middlename` = TRIM( REPLACE( REPLACE( j.`name`, SUBSTRING_INDEX( j.`name`, ' ', 1 ), '' ), SUBSTRING_INDEX( j.`name`, ' ', -1 ), '' ) ), cb.`lastname` = TRIM( SUBSTRING_INDEX( j.`name`, ' ', -1 ) )

and It worked Thanks.
Last edit: 11 years 4 months ago by krileon.
The following user(s) said Thank You: krileon

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

Moderators: beatnantkrileon
Powered by Kunena Forum