• Report Links
    We do not store any files or images on our server. XenPaste only index and link to content provided by other non-affiliated sites. If your copyrighted material has been posted on XenPaste or if hyperlinks to your copyrighted material are returned through our search engine and you want this material removed, you must contact the owners of such sites where the files and images are stored.
  • Home
  • -
  • New Pastes

Customizing the layout with custom user fields

  • Thread starter XMAN
  • Start date Aug 2, 2021
X

XMAN

Well-known member
Joined
Jul 12, 2021
Messages
33,395
Reaction score
249
Points
63
  • Aug 2, 2021
  • #1
This is a simple guide explaining how custom user fields can be used to customise the layout and allow members to have some form of control over the content, depending on the options you provide.

For the purposes of this guide, we will be creating a checkbox for members to opt out of seeing the forum statistics in the sidebar.

Create the custom user field

The first step is to create the custom user field, like so:





A new option will then be present on the account preferences page.



Edit the widget

Now we enter a conditional statement in the widget display condition field to show the widget when the field is unchecked.
The code for that is:

Code:
!
Code:

$xf.visitor.Profile.custom_fields.removeStatistics




Note how removeStatistics matches the ID of the custom user field.


That's it!
Any member who now checks the field in their preferences will no longer see the widget in the sidebar.


The same approach can be used for templates, forums, etc.
Just use the custom user field ID with a conditional statement to show/hide content

Continue reading...
 
Upvote 0 Downvote
You must log in or register to reply here.
Share:
Facebook Twitter Reddit Pinterest Tumblr WhatsApp Email
  • Home
  • -
  • New Pastes
  • Terms and rules
  • Privacy policy
  • Help
  • Home
AMP generated by AMPXF.com
Menu
Log in

Register

  • Home
    • Go Premium
  • Go Premium / Advertise
  • New Ad Listings
  • What's new
    • New posts
    • New Ad Listings
    • Latest activity
  • Members
    • Registered members
    • Current visitors
X

Privacy & Transparency

We use cookies and similar technologies for the following purposes:

  • Personalized ads and content
  • Content measurement and audience insights

Do you accept cookies and these technologies?

X

Privacy & Transparency

We use cookies and similar technologies for the following purposes:

  • Personalized ads and content
  • Content measurement and audience insights

Do you accept cookies and these technologies?