Skip to Content Skip to Menu

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

5 years 3 months ago - 5 years 3 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:
Code:
<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?
Last edit: 5 years 3 months ago by krileon. Reason: Added [SOLVED] tag to subject

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
5 years 3 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 or Create an account to join the conversation.

5 years 3 months ago - 5 years 3 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:
Code:
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 !!!
Last edit: 5 years 3 months ago by jgardounis.
The following user(s) said Thank You: krileon

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

Moderators: beatnantkrileon
Powered by Kunena Forum