Hi,
I try to display simple webform submission result on /user/xx page and allow all roles except anonymous user could see (pure read only). Just hope somebody tips me what I miss.
- I have limited one user one submission, and the user only could edit / delete his own submission.
- Assume the system will require all users filling up their webform.
- I have cloned 4 authenticated user roles (these 4 roles exactly the same permission as authenticated user), so there are 6 roles in drupal.
- I applied the patches (webform-273837-69.patch & webform.module_14.patch).
- I set up two webform (node/34 & node/33). Supposed the names of 4 roles are A,B,C,D, A and B could submit node/34 and C and D could only submit node/33.
- I tried to implement hook_user() (it obviously does not work):
/**
* Implementation of hook_user().
*/
function webform_user($op, &$edit, &$account, $category = NULL) {
switch ($op) {
case 'form':
break;
case 'view':
global $user;
$submission = array();
$submission_count = 0;
// Get a count of previous submissions by this user.
if ($user->uid && (user_access('access own webform submissions') || user_access('access webform results') || user_access('access webform submissions') || (user_access('access own webform results') && $user->uid == $node->uid))) {
$submission_count = db_result(db_query('SELECT count(*) FROM {webform_submissions} WHERE uid = %d', $user->uid));
}
// Render the form and generate the output.
$form = drupal_get_form('webform_client_form_'. $node->nid, $node, $submission, FALSE, FALSE);
$account->content['webform'] = array('#value' => $form, '#weight' => 1);
break;
case 'submit':
break;
}
}
Comments
Comment #1
zanhsieh CreditAttribution: zanhsieh commentedErr..
should change to:
My bad.
Comment #2
djalloway CreditAttribution: djalloway commentedI do not have a direct answer for you, but I will offer that I have been able to get this type of feature working using a few things.
Latest versions of the following.
And here is what I did.
Webform submissions
type that the above Patch providesNow I have a new tab on my User Account page that says "My submissions" that will show that specific users submissions.
Viola.
If it sounds a bit complicated I understand, but it's the only way i've been able to get user specific Webform data on the My account page.
Comment #3
zanhsieh CreditAttribution: zanhsieh commented@djalloway:
Wow! Thanks a lot for help.
On webform.module, there are two places need to change:
First one:
should change to
Second one:
Should change to:
People intend to use the solution above should apply the code and then assign the 'access webform submission' right to the user role.
Meanwhile before djalloway replied to my request, I implemented hook_user() interface:
Pure text mode output to individual user profile page.
Comment #4
rcrowe CreditAttribution: rcrowe commentedI am a Drupal newbie and am trying to do a similar thing. I have a feedback form made with the Web Form module that I'd like to display the results from on a page. Anonymous users should be able to view it. I have installed the Views Webform module, and have made a View page for the feedback. The relationship is Webform Submissions: node and I have a filter for the node for this particular form. I'd like to have the results display on the page, along with the date they were submitted. But, when I try to add fields the only ones available are the date submitted and a link to the results. Is there a way I can display the feedback text instead of just a link? You can see the page at http://yoga.rhettcrowe.com/feedback-results.
Comment #5
quicksketchYou cannot display individual values because no implementation has been written to show the data from the webform_submitted_data table. See #680386: Views integration for the webform_submitted_data table. The custom theming above is outside the scope of help provided in the Webform queue, so if you decide to go that way you're on your own.