17th Mar '23
/
5 comments

Bricks Condition for WishList Member

Looking to render a Bricks builder element only if the user has access to a specified WishList Member level?

Add the following in child theme‘s functions.php (w/o the opening PHP tag) or a code snippets plugin:

// Function to check if the current user belongs to the specified WishList Member level.
function bl_user_has_wlm_level( $level ) {
	return wlmapi_is_user_a_member( $level, get_current_user_id() );
}

and apply a dynamic condition like this:

{echo:bl_user_has_wlm_level(1679020379)}

where 1679020379 is the ID of the membership level.

Reference

https://wishlistmember.com/docs/knowledge-base/function-reference-wlmapi_is_user_a_member/

Get access to all 610 Bricks code tutorials with BricksLabs Pro

5 comments

  • Hi, this is great. Thanks Sridhar!

    Wondering how I would edit it so only manually approved users of a membership level can access? Looks like something to do with this:

    wishlistmember_approve_user_levels (action) Called when a member is approved on one or more levels Parameters: $id - Member ID $levels - Membership Levels

    For reference that is from: https://wishlistmember.com/docs/membership-level-hooks/?

    • A

      Hi Matt. Per my understanding that hook can not help identify whether a user got automatically added to a specific level or manually by the admin. Going by the description on that doc page of "Called when a member is added to one or more levels" I don't think it is referring to manual approval of users.

      Try contacting WLM support and ask if there is a function that returns a boolean (true or false) based on whether a given user has been manually approved or not. Keep us updated.

Leave a Reply to Matthew van der Ende (Cancel Reply)

 

Related Tutorials..

Pro
User Role Conditional Output in Bricks

User Role Conditional Output in Bricks

This Pro tutorial provides the steps to output elements based on their CSS class to users of the specified role in WordPress when using Bricks…
Categories:
Pro
Conditional Output in Bricks based on if Content has Headings

Conditional Output in Bricks based on if Content has Headings

How to prevent the output of the table of contents if the content has no headings.
Categories:
Tags:
Pro
Conditional CSS in Bricks based on Post Meta

Conditional CSS in Bricks based on Post Meta

In the Bricks Facebook group a user asked: Hi, how do you normally control margin, padding and font-size using dynamic data? I'm looking for the…
Condition for Checking Current Post Category in Bricks

Condition for Checking Current Post Category in Bricks

How we conditionally display an element based on the current post's categories.
Categories:
Check if a given category has at least one post

Check if a given category has at least one post

There could be situations where you want to check if a given category (by its slug) has at least 1 post assigned to that category.…
Categories:
Pro
Bricks Dynamic Condition – Check if today falls within 5 days before any holiday date

Bricks Dynamic Condition – Check if today falls within 5 days before any holiday date

Creating a custom condition that returns true or false depending on whether today falls within 5 days before any holiday dates selected on a Meta…
Categories:
Tags:
Pro
Showing a Popup conditionally in Bricks based on Query Parameter

Showing a Popup conditionally in Bricks based on Query Parameter

Here's two ways a Bricks Popup can be shown on page load depending on URL parameter value.
Categories:
Tags: