Skip to Content Skip to Menu

how can set field value to be uniqe

  • saman2
  • saman2
  • OFFLINE
  • Posts: 405
  • Thanks: 7
  • Karma: -1
4 years 7 months ago #317867 by saman2
how can set field value to be uniqe was created by saman2
hi.
i want my user have uniqe field value. for example each user with his mobile phone number can register one time in my site and prevent from register two user with duplicate mobile phone number. how to do that? need use code field? is there any easiest way?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
4 years 7 months ago #317882 by krileon
Replied by krileon on topic how can set field value to be uniqe
Install CB Query Field then use its Query Validation on your Text field under Integrations > CB Query Field to validate other users values for that field. Example as follows.

Code:
SELECT `id` FROM `#__comprofiler` WHERE `cb_phone` = '[value]' AND `user_id` != '[user_id]' LIMIT 1

This would return a positive result if someone has the same cb_phone value, which can be used to fail the fields validation.


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.

  • saman2
  • saman2
  • OFFLINE
  • Posts: 405
  • Thanks: 7
  • Karma: -1
4 years 7 months ago #317895 by saman2
Replied by saman2 on topic how can set field value to be uniqe
i have another problem, is it possible use two ajaxify validation? one "code field" and other "query field"? when use this two validation,there group of validation is "OR" or "AND"?means if i have two validation which of that need to verify or both of that need to verify? if i want both need to verify what need to do?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
4 years 7 months ago #317918 by krileon
Replied by krileon on topic how can set field value to be uniqe
Yes, you can use Code and Query validation at the same time. Both would need to pass their validation checks so it is an AND scenario. If you need an OR case you'll need to use API to run your query in the Code action and just combine the two validations.


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.

  • saman2
  • saman2
  • OFFLINE
  • Posts: 405
  • Thanks: 7
  • Karma: -1
4 years 7 months ago #317989 by saman2
Replied by saman2 on topic how can set field value to be uniqe
But when I use that two validation , the query validation ignored. Is it related to set ajaxify validation on both?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
4 years 7 months ago #318001 by krileon
Replied by krileon on topic how can set field value to be uniqe
The query validation shouldn't be ignored, but it's going to have to pass validation of whichever plugin is loaded first before the other validation will trigger. Are you saying no matter what only 1 ajax validation is working at a time?


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.

Moderators: beatnantkrileon
Powered by Kunena Forum