[SOLVED] Conditional image based on Member Since field (registerDate)

4 years 7 months ago - 4 years 7 months ago #313906 by jgardounis
So I want to have on the profiles of every member a sort of image/award showing up based on how many months/years they are registered members.

I have the following awards: 6 months, 1 Year, 3 Years, 5 Years, 7 Years and 10 Years and I want to display either of them based on how lond they have been a member.


In the following I will use the example of the 6 months award:


So what I did is create an image field for each award and in the Profile Value Layout of each field I added the html with the source of the image like this:
<div class="award-display"><img title="6 Months of Membership" src="/images/awards/6-months-image.png" /></div>

Then I went to Integrations > CB Conditional and in the Display I chose Field Conditional Show.

In the Conditions i selected the following :

Field : Member Since (registerDate)
Operator : Greater than or equal
Value : 182
(I assume that it calculates the days between current date and date of registration)


and I added an AND row with the following:

Field : Member Since (registerDate)
Operator : Less than
Value : 365


So based on the above the expected result is if Member Since field is between 6 months (182 days) AND less than 1 year (365 days), then it should display the award, else hide it.

The problem is it displays it to all members despite some being members for more than a year.

Any ideas?

Please Log in to join the conversation.

4 years 7 months ago #313907 by krileon
Member Since (registerDate) is just a datetime. It's not the number of days they've been registered. At this time there is no special date condition handling. There likely isn't a way to do what you're wanting without the help of CB Query Field and a Query field to calculate the number of days they have been registered then conditioning against that. Once CB Conditional has Format Functions like CB Auto Actions this will be possible out of the box in CB Conditional, but I don't know when those will be implemented.


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.
The following user(s) said Thank You: jgardounis

Please Log in to join the conversation.

4 years 7 months ago - 4 years 7 months ago #313908 by jgardounis
I have CB Conditional, but I am not sure how to start.

From what understood I need to make a custom field that calculates the age of the membership, correct?

I am not sure what the CB query field does or how it differs from the Query field you mention.

EDIT: I applied what you suggested and it works. This is what I did:

I used this query to create a field called registerDate which returns the amount of months since the registration of each member:
SELECT TIMESTAMPDIFF( MONTH,  `registerDate` , CURDATE( ) )  AS cb_registerdate
FROM  `jos_users`  WHERE `id` = '[user_id]'

which is something I discovered searching these forums ( Link )

And then I modified the image field to have the following conditional settings:

Field : registerDate (registerDate)
Operator : Greater than or equal
Value : 6


and I added an AND row with the following:

Field : registerDate (registerDate)
Operator : Less than
Value : 12

Now it works. Thank you for your guidance !!!
The following user(s) said Thank You: krileon

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 1.179 seconds

Facebook Twitter LinkedIn