CB referred by field

2 years 8 months ago #325921 by kdave321
CB referred by field was created by kdave321
One of the first things I did in CB was added a "referred by" field so I could see within someone's profile who invited them.

So, I'm posting this because it seems like something everyone would want to know.

First, I would like the invited person to see on their registration page the name of the person who invited him.
1) I retrieve the user_id from #__comprofiler_plugin_invites based on the invite code
2) Display firstname lastname of the user_id on registration and in the profile.

Suggestions on how you would do this? Can it be done with a single CB field? ( where stored value and displayed are different). Does this functionality already exist some where?

Please Log in to join the conversation.

2 years 8 months ago #325932 by krileon
Replied by krileon on topic CB referred by field
The below should work using a Query field provided by CB Query Field plugin.

Parameters > Query
Query:
SELECT `user_id`
FROM `#__comprofiler_plugin_invites`
WHERE `user` = '[user_id]'
LIMIT 1
Parameters > Display
Output: Single Row
Columns: Multiple Columns
Display: Custom
Custom:
[cb:userfield field="formatname" user="[column_user_id]" /]

That should output the formatname field of the user who invited them through CB Invites. Will review adding this as a field to CB Invites itself as it could be useful for several usecases.

forge.joomlapolis.com/issues/8662


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.

2 years 8 months ago #325939 by kdave321
Replied by kdave321 on topic CB referred by field
OK, that works, altho I don't understand where the [user_id] is coming from on the registration page. I thought I would have to do a "where code = '[get_invite_code]'" but that doesn't work.

I used to have to set the invite_code from the URL with a trigger and JQuery command but I see that's working now.

Thanks!

Please Log in to join the conversation.

2 years 8 months ago #325942 by krileon
Replied by krileon on topic CB referred by field
This won't be able to work on the registration page. It will only work on their profile. Registration page can only show the invite code field and it has no functionality to grab who invited them. Note the invite code field is not needed anymore unless you want your site to be invite only. Simply using the invite link now stores the invite code to their session data and will accept during registration.


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.

2 years 8 months ago #325951 by kdave321
Replied by kdave321 on topic CB referred by field
I wouldn't have thought it worked on registration either - but it does. I made a new invite code and my name was on the registration page (obviously I was not logged in at that point)

My site is invite only. Now that I know the field is working I no longer have to display it. However, I also add some members without registration so I will now need to handle that.

Please Log in to join the conversation.

2 years 8 months ago #325959 by krileon
Replied by krileon on topic CB referred by field

I wouldn't have thought it worked on registration either - but it does. I made a new invite code and my name was on the registration page (obviously I was not logged in at that point)

That's probably because [user_id] is 0 at that point. So it's just pulling the first invite that hasn't been accepted yet. I don't recommend displaying it on registration. It's possibly it could work on registration with the help of CB Core Fields Ajax and its Update On feature combined with checking against the database using the invite code.

My site is invite only. Now that I know the field is working I no longer have to display it. However, I also add some members without registration so I will now need to handle that.

If your site is invite only you need to use the invite code field and make sure it's set to Required. However under Parameters > Display you can toggle it to be hidden so it's not visible, but its validation can still work. As for adding users manually the best way to do that is within backend, but you'll need to be sure to turn off backend field required validation in CB > Configuration > User Profile.


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.183 seconds