5

I have an address field for every user on my website. Now, not everyone is happy with having his address visible to other users. I'm currently using field_permissions to control the visibility of the single fields. Is it possible to let the user decide which visibility he chooses (without code)?

2

Field permissions is role based, so I think it's not good choice to work with for this certain scenario. You can simple add another field to indicate whether others can see value of the field.

Then you can use hook_field_prepare_view to hide selected field value or try to find better hook.

If you want to have more advance solution you can create your own field type with two inputs: text field (value) and checkbox (value private or public).

You can use Field Permissions for higher level of access control too.

5

If you want to do this without writing any custom code, you could use Panels.

Create a boolean field, Show my address publicly, and add it to the user profile.

Then override the user profile display with Panels. Add all of the fields that you want to display, including the address field. Then, add a Visibility rule to the address field and set the condition to be Show my address publicly == TRUE.

This is a bit complicated to set up if toggling the display of the address is all you want to do, but Panels offers a lot of flexibility (without writing code) that could be used for other things, too.

  • 2
    That's a nice solution without coding. However, this visibility will probably not affect how the address will be displayed in views for example? – Turion Aug 4 '13 at 14:32
  • @Turion That's correct, Views will still show the address. You would have to customize all the views as well (in such a case, it would be better to write a little custom code than to do a huge number of steps to avoid writing any.) – Patrick Kenny Aug 4 '13 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.