1

On our rebuilt site we have an "about me" field attached to the user account. We want to give people the ability to specify who can see this information (or their whole user profile):

  • Anyone (anonymous users)
  • Authenticated users only
  • paid Members of the organisation only (a role).

What's the best way of doing this?

  • Custom code would be the best way (assuming by "best" you mean most efficient in terms of operation) – Clive May 1 '17 at 10:57
1

Assuming that by "best" you mean that you want to avoid custom code if possible (e.g. because you don't have the skills and/or budget for that), then this is a way to make it work with zero custom code:

  1. Implement your "About me" field as an entity reference, which references a node of some other content type (say "Details About Me"). So if somebody wants to complete such field, they should first have created an appropriate node of content type "Details About Me" (so that they can use that node in their entity reference field.
  2. Add a special (required) field, which you define as a single value selection field, to let the user "specify who can see this information" (as in your question). Say you call such field "Visibility".
  3. Whenever somebody wants to browse such "Details About Me" page, let the Rules module decide if such browse is yes or no allowed (based on the content type, and the value of that Visibility field. Refer to the answer to "How to make the permissions of a module more granular?" for a sample rule you could start from, and make it fit your case like so:

    • Adapt the Rules Conditions.
    • Tune the redirect URL and message in the Rules Actions.

The above should take care of the "specify who can see this information"-part of your question. The remaining part of your question (= "or their whole user profile") is really a different question, not answered here. Though you could use a similar approach for that also.

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.