Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › [Help] Restrict the use of "Add to cart" button only to registered user › Reply To: [Help] Restrict the use of "Add to cart" button only to registered user
I can give you some guidance on what to do but essentially to be able to customize this to your hearts content you will need to have PHP skill (it is beyond my capability to get you up to speed on PHP).
Please open the “eStore_misc_functions.php” file and look for the following function:
function get_button_code_for_element
once you find this function just add the following bit of code just inside the function.
if (!is_user_logged_in())
{
$output .= "You must be logged in to purchase";
return $output;
}
So after the modification it will look similar to the following:
function get_button_code_for_element(........)
{
if (!is_user_logged_in())
{
$output .= "You must be logged in to purchase";
return $output;
}
.....
.....
This will make it so the button won’t get displayed to non logged in users. Instead it will display the “You must be logged in to purchase” message.
If you are creating a membership site I think you will need a WordPress membership plugin. This will give you the ability to hide the button behind a protected page so only members can access the button and so on.