How To Restrict Custom Fields Per Membership

Note: if you are using the PMPRO version of the theme, rename the functions listed within this article from "tdp_" to "pmpro_" (only the prefixes).

First of all you need to get the ID of the memberships that you want to restrict. Once you got the id(s) open file functions.php and at the bottom add this code

Now, at first you need to modify the array that you see in this line

Modify those numbers with the ID(s) of the membership that you want to restrict.

Also, you need to specify which field you need to hide. To do so, you need to modify the field name into this line

 

add_filter('acf/load_field/name=custom_field_name', 'tdp_restrict_custom_field');

Modify the name parameter, remove “custom_field_name” and place the name of your custom field. Note: the name isn’t the label, but the value of the name parameter from the code that you generated for your own field.