php - hide price and add_cart for anonymous user in drupal

20

How do I hide price and add_to_cart option for anonymous users in Drupal?

786

Answer

Solution:

I think, You can go page dmin/people/permissions and uncheck this option for anonymous.

To hide fields you can create node--YOUR_CONTENT_TYPE.tpl.php

In this template you can check user-role:

global $user;

// Check if the user has the 'authenticated user' role.
if (in_array('authenticated user', $user->roles)) {
  //show your field 
}

Also you always can hide from css -)

.not-logged-in .YOUR_CLASS_FIELD {display: none;}

People are also looking for solutions to the problem: php - NULL radio button value

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.