This is an interesting idea, unfortunately I don’t think this can be done simply with the plugin as is. You could conceivably do this with JavaScript and a hardcoded form for selecting the company, though it would be a bit of a hack. You could put the [formdata] within a hidden div, use a script to scrape all of the submission data, and then show the records that match the selected company.
Hi,
I’ve the opposite problem, that I can’t restrict the records to the logged in user. Everybody can see all records. How can I prevent them to see records from other users?
Please help
Thanks in advance
Oskar
Oskar,
You could do this with a filter. I didn’t document it in the FAQ, but it will solve your problem. First you need to make a blank plugin. There is a template on my site for a custom submission action, that will work, but you would want to remove the add_action stuff that comes with it and replace it with the following:
add_filter( 'fm_data_query_clauses' , 'fm_addUserClause' );
function fm_addUserClause( $clauses ){
$clauses[] = "<code>user</code> = '".$current_user->user_login."'";
return $clauses;
}
I just noticed something got messed up with the code I posted. Just remove the parts where it says <code>
and </code>
and you should be fine.
Hrm… as the administrator I am not seeing the submissions but as a logged in user I am still seeing all submissions on the actual wordpress page where I have the slug… any way to correct that?
The submission data slug is not user aware so there is no way to restrict access, but I don’t know why the admin would not be seeing the submissions. That sounds like a bug.
Sorry to start this again but the subject fits my question.
I am creating a site for our company. It’ll be intranet where the team-members have a page each where they can see their submitted data.
Is there a way to create a summery template for each team-member which will then only pull the submitted data that user?
I would like to create pages where only the team manager and each team-member have access so so they then can review the data together.
Would apreciate your help!
Thanks
There isn’t an easy way of doing this.
Hello Hoffcamp
I have the same problem as Oskar321.
In which file do I have to edit the code you give ? What do you mean by “a blank plugin” ?
You could put the code into functions.php in your theme, just remember to redo the change if you update the theme. BTW the original code had an error in it. The corrected code is here:
add_filter( 'fm_data_query_clauses' , 'fm_addUserClause' );
function fm_addUserClause( $clauses ){
$clauses[] = "user = '".$current_user->user_login."'";
return $clauses;
}
Thanks Hoffcamp.
It doesn’t work. I’ve added your four lines of code at the end of my file functions.php of the basic theme (TwentyEleven.
When I open a page which show the records of a form (shortcode [formdata form-1]) I still get the record recorded by other user and not only those of the logged user.
Is there something else to do ?
My mistake – the code restricts access on the ‘Submission Data’ page, not the formdata shortcode. There isn’t a way to alter the behavior of the formdata shortcode. If you are comfortable formatting the results yourself, you could query the form’s data table directly and check against the ‘user’ column.