I have a type downloadable_item
which has a field field_roles_allowed
that is based on the Role Field Module.
My goal is to have a field_download
of file
type that will show the file for download if the user in a role selected in the field_roles_allowed
and a message that they need to request access otherwise.
I am attempting to add a formatter for the file field type using the Custom Formatters Module. I found this tutorial on how to use the Custom Formatters module, however, they use the "HTML + Tokens" option. I will need to use the PHP option to be able to output either the download button or a message depending on whether the user is in a role in the field_roles_allowed
.
I cannot figure out how to get the roles that are allowed, download file information, and current user's roles for comparison.
My question is really "How do I do these things that I cannot figure out?", but if someone believes I am going about this totally in the wrong way... I am open to another way.
EDIT: I solved my own problem below, but not really in a preferable way. How could this be done without writing PHP logic in field?