Skip to Content Skip to Menu

[SOLVED] Using Delimited Field to Adjust lastname string

  • iSuck
  • iSuck
  • OFFLINE
  • Posts: 14
  • Thanks: 0
  • Karma: 0
12 years 7 months ago - 12 years 7 months ago #178680 by iSuck
Hi,

I have a review website. To prevent reprisals for bad reviews I need to protect the last name of the reviewer. During registration I need to capture the full last name. On the users profile I need the only the last name initial to show. Does anyone know how to do this with a delimited field?
Last edit: 12 years 7 months ago by krileon.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 68629
  • Thanks: 9110
  • Karma: 1434
12 years 7 months ago #178737 by krileon
Can't do it with a delimiter field as it's purely HTML and no PHP logic available. You'll need to use incubator project CB Query Field with the below query.
Code:
SELECT UCASE( LEFT( '[lastname]', 1 ) ) FROM DUAL

If for some reason your database doesn't support the dummy table DUAL you can use the below.
Code:
SELECT UCASE( LEFT( `lastname`, 1 ) ) FROM `#__comprofiler` WHERE `id` = '[user_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.

  • iSuck
  • iSuck
  • OFFLINE
  • Posts: 14
  • Thanks: 0
  • Karma: 0
12 years 7 months ago #178790 by iSuck
Thanks for the help. I tried both codes using CB Query Field, but each time the field only outputted a "-". Could it be because my website is in a subdomain and not the main domain?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 68629
  • Thanks: 9110
  • Karma: 1434
12 years 7 months ago #178843 by krileon
Domain has nothing to do with it, it's simply a query that grabs the first letter of the lastname. If there is no lastname then it won't do anything. It depends on what your name format is set to within CB > Configuration. It would need to be first and last name or first, middle, and last name display modes. Simply name field would require a more complex query.


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.

  • iSuck
  • iSuck
  • OFFLINE
  • Posts: 14
  • Thanks: 0
  • Karma: 0
12 years 7 months ago #178887 by iSuck
Ok my name style in CB Configuration Manager is set to "First and Last Name Field". When a user registers the enter a first and last name, those fields are populated. I also double checked in User Management to make sure first and last names existed in those fields and they do.

I have also created a query field with field name cb_lastinitial and tried the different variations of query code one at a time, into the Field-specific Parameters text area with mode Internal selected. The cb_lastinitial field is set to published. The CB Query Field plugin is installed and also published.

Do you know of anything else I can try?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 68629
  • Thanks: 9110
  • Karma: 1434
12 years 7 months ago - 12 years 7 months ago #179023 by krileon
The second query is what you should likely be using then as it'll ignore permissions or anything of the sort. The only other option is to pull name directly from _users, break it into first/middle/last then grab the first letter of the last name which is a much more complex query. The second query I have confirmed working fine please ensure you've directly copy and pasted it to the fields configuration. Please also ensure your host is using at minimum MYSQL 5.0.


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.
Last edit: 12 years 7 months ago by krileon.

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

Moderators: beatnantkrileon
Powered by Kunena Forum

Facebook Twitter LinkedIn