What I am looking to do is pull in an entry value into the “before” section on a custom display. I have several custom displays setup and they are displaying data based on various get_param requirements.
So on one page I have something like this:
http://www.mysite.com/employee/?emp=6
which is showing data for employee with the id 6.
On that same page I want to output the VALUE of employee id 6, which in this case is the employee’s name. Is there something like this that I can do?
[get_value 95="[get_param=emp]“]
Where 95 would be the field id, and the = is the id of the entry for that field, in this case it would grab whatever the emp from get_param is.
Let me know, this would be EXTREMELY useful if there is a way to do this!




September 28, 2012 at 7:11 pm
Here's a shortcode you can add.
http://formidablepro.com/help-desk/get-entries-value-in-another-form/
We will most likely add a similar shortcode in a future release.
October 7, 2012 at 12:06 am
I'm trying implement this in these ways:
echo do_shortcode('[frmfieldval field_id=95 entry_id="[get param=emp]"]');
In a template, and also via
[frmfieldval field_id=95 entry_id="[get param=emp]"]
In a page, and in the "before" section of a custom display all with the result of :
"]
Doesn't seem to be parsing the [get_param=emp] nested shortcode. Is doing this possible? Using the short code with an explicit entry_id does work however, but I need this to dynamically display the entry based on the parameter.
Thanks Stephanie! Keep up the amazing work!
October 8, 2012 at 10:50 am
In your template, you can use
frmfieldval_shortcode(array('entry_id' => $_GET['emp'], 'field_id' => 95));
There have been a couple people who have stated this works in the before content box, but we have been unable to replicate:
[get param=emp]
[frmfieldval field_id=95 entry_id="[get param=emp]"]
October 8, 2012 at 2:13 pm
Doesn't seem to be outputting anything. I tried with an echo and without.
echo frmfieldval_shortcode(array('entry_id' => $_GET['emp'], 'field_id' => 95));I really appreciate your patience in helping with stuff like this. I know it's probably pretty simply php/sql stuff, but it's all still pretty complicated for me! :)
Also is it wise to use $_GET directly due to security concerns, or should it be assigned to a new array which contains cleaned superglobal variables?.... something like $_CLEAN['GET'] = clean($_GET);
October 8, 2012 at 2:20 pm
Where are you putting this? Do you have a php plugin installed? Is there a ?emp=5 or something in your url?
October 8, 2012 at 2:23 pm
Still working on this project: http://formidablepro.com/help-desk/advanced-custom-display-questionproblem/ For reference...
The URLs look like http://ltdev.gunnargabrielson.com/employee/?emp=6 with the 6 being the entry ID for the employee. See the above post for how the displays are setup.
October 8, 2012 at 2:28 pm
I did however get this to work perfectly:
echo frmfieldval_shortcode(array('entry_id' => $_GET['emp'], 'field_id' => 86));Which outputs the employee's name.....
edit: Haha okay I see where the messup is. I was looking at the other piece of code thinking it was the stats function... derp. I think I have this figured out / working now.
October 8, 2012 at 2:33 pm
Okay so the other thing I'm trying to do is use the same technique but with the stats shortcode:
[frm-stats id=140 95="[id]" type=average round=1]How would I implement that using what you've got in the documentation:
echo FrmProStatisticsController::stats_shortcode(array('id' => x, 'type' => 'average', 'user_id' => 'current'));October 8, 2012 at 3:42 pm
This is what I tried but didn't get a result... am I on the right track?
echo FrmProStatisticsController::stats_shortcode(array('id' => 140, 'type' => 'average', 'round' => 2, 'value' => $_GET['emp'] ));October 8, 2012 at 3:56 pm
What type of field is 140? Does it hold numeric values?
October 8, 2012 at 3:56 pm
I found that the value code is working right on the main custom display but when clicking on the details link it breaks because the parameter changes to ?sub= .....
Is there a way I could overcome that? Assign it to a variable or something? I feel more and more over my head on this project, haha...
October 8, 2012 at 3:58 pm
140 is the field that averages the results from about 25 scale questions (1-10).
Its an employee evaluation form that gets filled in and then averages all the questions together to give a score.
October 8, 2012 at 4:01 pm
This is the code for the final custom display template (which is a dynamic display):
http://pastebin.com/AwaAe5Hm
October 8, 2012 at 6:59 pm
The reason is isn't working, is because value => 6 will only include values in the calculation that are equal to 6. This isn't what you're after. Instead of value => $_GET['emp'], use 15 => $_GET['emp'] (replace 15 with the ID of the field that matches up with the 'emp' value in the url) or 'user_id' => $_GET['emp'] if it's in a user ID field.
October 9, 2012 at 9:56 pm
One last question on this subject!
So what I am trying to do is on this page:
mysite.com/employee/?emp=6 (number will change obviously depending on what employee you are looking at)
I am trying to display the photo associated with that person, which is one of the fields in the form to add an employee (Name, Photo, Department, Location are the fields).
So I need to display the file upload (the image) from field id 178 for entry id based on the parameter. Is there a way to use that shortcode to do that?
add_shortcode('frmfieldval', 'frmfieldval_shortcode');
function frmfieldval_shortcode($atts){
extract(shortcode_atts(array('entry_id' => false, 'field_id' => false), $atts));
global $frmdb, $wpdb;
$empname = $_GET['emp'];
$field_val = $wpdb->get_var($wpdb->prepare("SELECT meta_value FROM $frmdb->entry_metas WHERE field_id=%d and item_id=$empname", $field_id, $entry_id));
return $field_val;
}
Just using this code to output an employees name works great, but trying to use it to output the employee's picture doesnt work, instead it just outputs a number.
I can do this easily enough inside the display loop using [95 show=178] but I am trying to display this outside the loop in the before section, like how I did with the name.
October 10, 2012 at 10:12 am
When you were just wanting to retrieve one field, that shortcode was an acceptable solution. However, this is more complex than you indicated previously. We recommend using custom displays for this type of thing.
http://formidablepro.com/knowledgebase/display-your-form-data/
October 10, 2012 at 2:06 pm
Thanks Stephanie, you are as always infinitely patient and give the best support. Sorry if some of my questions stray outside the general scope of what you usually/want to offer for support.
I actually for some dumb reason hadn't realized I could insert custom displays within custom displays. I just made a custom display that pulled the image, and used the shortcode for that display in the main display. Worked like a charm!
Only thing is it outputs the image in the 150x150 thumbnail size, where would I change that default size, or register a custom thumbnail size and assign it to that.
Thanks so much!
October 10, 2012 at 5:50 pm
You can specify a different size in the custom display. The size options are shown in the sidebar of the custom display settings and in the dropdown above the content box used to insert the shortcodes.
<img src="[25 size=full]" alt="" />
October 10, 2012 at 6:13 pm
Thanks Stephanie... until next time!
Cheers!
Topic closed.