3

How do I create a view which is embedded in a Panel overriding the Drupal User Page, which shows the data from a CiviCRM profile ONLY to the currently logged in user, and that user has permission to see their own data in CiviCRM. The goal is to make a pane which shows some basic information about their civi contact record, so they can click a link, and edit it, and return to see it changed. Thanks!

2
  • For the sake of clarity, you are not wanting to use the Drupal User page at all, correct? So marking the Profile as 'Drupal User Registration' or 'View/Edit Drupal User Account' in the Profile Settings in Civi is not an option because that integrates into the Drupal User Page? Commented Nov 6, 2015 at 18:05
  • I am using the Panels module to override the /user page with a custom layout and views. I want to use the Views module to display CiviCRM fields that are pertaining to the currently logged in users CiviCRM record, and display them on their /user page as a panel pane. I do not want other users to see their private fields.
    – Zachary
    Commented Nov 7, 2015 at 18:58

3 Answers 3

1

To answer your question: "What permission would just allow users to see their own results of this view?"

Views Solution (if users still need to be able to visit other users' user-pages)

Picking up from Coleman's answer, using a contextual argument (we've used "CiviCRM Drupal match table: Drupal User ID" with success), you provide a "Default value" of 'User ID from the logged in user'. Then, to limit the view to be viewable by each user only, scroll down in the contextual argument window and "Specify Validation Criteria" with a "Validator" of 'User'. Only allow 'Numeric UIDs' and for "Action to take if the filter value doesn't validate", choose 'Hide View.'

enter image description here

When User X visits his/her own user-page, the view will display. However, when User X visits User Y's user-page, User X will not see the information the View provides.

Drupal Permissions Solution (if users do not need to visit other users' user-pages)

If authenticated users have the Drupal permission "View User Profiles" under the 'User' section, then all users who are logged in would be able to see the results of the view, if the view is otherwise unrestricted. If you remove that permission, your view would be limited to the logged-in user only.

2
  • Thank you. I want them to be able to view the user profile for some information, but not for the information this view provides.
    – Zachary
    Commented Nov 7, 2015 at 19:00
  • 1
    Hi Zachary, I've added a Views-only solution which I think will help. Commented Nov 7, 2015 at 22:16
3

To get a Drupal View to show only the civi data that belongs to the current user, set up a View Relationship to join the Civi Contact to the Drupal User. Then add a Filter using 'current user = Yes'. Should do the job. Hopefully my terminology is close enough to what it says on the page

1

You cannot embed a civicrm profile in a drupal view. Using the user id as an argument and a relationship to the contact, you should be able to construct a view that displays the contact data you want to show for the current user.

In the view header or footer you can place a link to either a civicrm profile form or a drupal webform with civicrm integration that will allow the logged-in user to edit their own contact record.

2
  • Thanks Coleman. My question might have been kind of weirdly asked, as usual :) I have made the view with the user ID as the arg and relationship to the current contact, but I am struggling with the view permissions. I can embed it on the user page, and the user can see it, but so can all of the other site users. What permission would just allow users to see their own results of this view?
    – Zachary
    Commented Nov 6, 2015 at 17:12
  • Can you edit your question to reflect that please?
    – Coleman
    Commented Nov 6, 2015 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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