1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.3 Create a Notice with Criteria (Empty Custom field)

Discussion in 'XenForo Questions and Support' started by Clovis, Feb 21, 2016.

  1. Clovis

    Clovis Member

    Hey Guys!

    I'm trying to setup a notice that is only visible to players who have one of their Custom Fields blank (empty).

    Is there any way to set the criteria if a field is empty? I've only been able to make it show up for those who had an entry in the custom field but not those who's field was empty.

    Thanks!
    Clovis
     
  2. Steve F

    Steve F Well-Known Member

    You could just use some HTML/CSS to build a notice with a conditional to show to the right users.

    I added the below to the ad_above_top_breadcrumb template.

    You would want to replace the user field ID with your own (portion in red).

    Code:
    <xen:if is="!{$visitor.customFields.customField1}">
    <div class="importantMessage">
    <p>Hi, I'm a notice!</p>
    </div>
    </xen:if>
    Results in:

    upload_2016-2-21_15-50-58.png
     
    Mr Lucky, adwade, wang and 1 other person like this.
  3. Clovis

    Clovis Member

    @Steve F : This worked perfectly. Thank you! :)
     
  4. adwade

    adwade Active Member

    This worked great for me as well. I even included a LINK to the Personal Details page in our notice, to make it fast & easy. (y)
     
  5. adwade

    adwade Active Member

    Using '$visitor' causes the notice to show up for visitors.(i.e. anyone not logged in)

    If I only want the notice displayed to members (who have a specific BLANK Custom User Field), once they are logged-in, what other variable could I use?

    I tried using '$member' to no avail. :confused:
     
    Last edited: Mar 12, 2016
  6. Steve F

    Steve F Well-Known Member

    Try

    Code:
    <xen:if is="!{$visitor.customFields.customField1} AND {$visitor.user_id}">
    <div class="importantMessage">
    <p>Hi, I'm a notice!</p>
    </div>
    </xen:if>
     
    radu81 and adwade like this.
  7. adwade

    adwade Active Member

    Genius, that worked beautifully! :)
     

Share This Page