DB Lookup plugin: applying to primary email field

10 years 7 months ago #233181 by zerodd
Hello there,

we are thinking about using the DB lookup field plugin to do some rather complex validation: we have a certain user type B, that may only register if a certain user type A user with an identical field value already exists.

More concretely: we are building a community for pharmacists, and pharmacy employees may only register if the OWNER of the same pharmacy already exists. We want to do this by checking the PRIMARY email address entered by any employee registering, against some other 'pharmacy email' address already provided by the pharmacy boss user (if he exists).

As you can see, this fits the DB lookup field plugin rather well, it would just take some modifying of the SELECT query to not look in a 'codes' table, but rather the comprofiler user table. However, as db lookup is a field type, it's impossible to apply its mechanism to the primary email field.

So what we're gonna do is some trickery where we create a second field at registration which ALSO contains the primary email address, and do the DB Lookup magic on that one.

(we can either explain it to the user why we ask this twice, but will probably just use JS to automatically duplicate the email into this second field, and some CSS to hide it entirely maybe)

... Is there a better way? Auto-actions come to mind?

Please Log in to join the conversation.

10 years 7 months ago #233183 by zerodd
Just a heads up: while writing, it occurred that yes, auto-actions are better suited to this - we already do some custom server-side validation with an onRegistrationSave (or what was it) auto action of type 'code' anyway, so this fits naturally.

And this way we don't have to use an extra plugin and mess with duplicate fields etc etc. So basically, the auto action will start like this:

if ($_POST = 'employee') {

//db lookup of $_POST etc etc

}

So, unless you have an even better way, I think we'll be going with this one. Auto actions rock, seriously :) Wonderful way to plug in our own wacky (because the client requirements are wacky) stuff in a nicely isolated way!

Please Log in to join the conversation.

10 years 7 months ago - 10 years 7 months ago #233184 by krileon
DB Lookup is basically depreciated. All you need now is CB Query Field, which includes multiple query type fields as well as provides query based field validation. You'd create a text field then enable query validation. You can then validate it to your needs using the below.

SELECT * FROM `#__comprofiler` WHERE `FIELD_NAME` = '[value]'

Then set it to validate on successful results. Replace FIELD_NAME with the name of the field you want to validate the value the user supplied against.

CB Query Field query validation also has an Ajax feature so it can validate the results without ever having to post the registration form, it's all instant.

CB Auto Actions isn't suited for what you're wanting to do.


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 to join the conversation.

10 years 7 months ago #233196 by zerodd

krileon wrote: CB Query Field query validation also has an Ajax feature so it can validate the results without ever having to post the registration form, it's all instant.

CB Auto Actions isn't suited for what you're wanting to do.


Aha, the AJAX thing is great - DB lookup didn't have that and that validation only on form submit, which is why we concluded, might as well use autoactions at this point for more control.

I'll look into the CB Query field! Though if I understand you correct, it is again a field type and thus not a validation procedure that can be applied to the primary email input field?

Please Log in to join the conversation.

10 years 7 months ago #233199 by krileon

I'll look into the CB Query field! Though if I understand you correct, it is again a field type and thus not a validation procedure that can be applied to the primary email input field?

CB Query Field does provide multiple fieldtypes, but the query validation is not a fieldtype. The query validation is global field parameters. You'll see them on the right side under your fields parameters for multiple field types. In other words you can apply the query validation directly to existing fields such as your email field.


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 to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.234 seconds

Facebook Twitter LinkedIn