Last active
July 4, 2024 10:04
-
-
Save wplit/505e34e22261c88bfbf2e401cb000ab5 to your computer and use it in GitHub Desktop.
check user status matches in specific membership level (RCP)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* custom function for checking status of user in membership (add to code snippets or child theme) | |
* @return bool True if user has the status in that memberhip. | |
*/ | |
function rcp_member_status( $membership_level, $status ) { | |
$customer = rcp_get_customer_by_user_id( get_current_user_id() ); | |
if ($customer) { | |
$memberships = rcp_get_memberships([ | |
'customer_id' => $customer->get_id(), | |
'object_id' => $membership_level, | |
'status' => $status | |
]); | |
return !empty( $memberships ); | |
} else { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Remember to include the custom function name "rcp_member_status" in the https://academy.bricksbuilder.io/article/filter-bricks-code-echo_function_names/