• I understand the shortcode [formdata (form-slug)] can only be used to retrieve data based on the logged-in user id. I would like my users to be able to retrieve any records from the database regardless of whether they submitted the data. For instance, there could be a drop-down list with a list of 5 companies A,B,C,D,E and I would like the user to be able to select let’s say ‘Company B’, this string would then be passed on to php through the address bar and a summary of the corresponding record would then be displayed and made editable using the behaviour type ‘User profile style’.

    Do you know what would be the most efficient way to get to this result?

    Thanks a lot for all your work on this great plugin, it’s really a wonderful tool!

    http://wordpress.org/extend/plugins/wordpress-form-manager/

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author hoffcamp

    (@hoffcamp)

    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

    Plugin Author hoffcamp

    (@hoffcamp)

    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;
    }
    Plugin Author hoffcamp

    (@hoffcamp)

    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?

    Plugin Author hoffcamp

    (@hoffcamp)

    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

    Plugin Author hoffcamp

    (@hoffcamp)

    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” ?

    Plugin Author hoffcamp

    (@hoffcamp)

    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 ?

    Plugin Author hoffcamp

    (@hoffcamp)

    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.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘[Plugin: WordPress Form Manager] Retrieve db record based on variable, not on logged-in user ID’ is closed to new replies.