Howdy again! I have another question for Stephanie or whoever…
I have a form that registers users (using the registration addon) and I have a couple of fields for additional user meta… Location and Department (using this to register employee accounts)… both of the fields are dynamic fields pulling in from a location add form and a departments add form. In the Settings I have two meta fields set up as such:
Employee Location = Location
Employee Department = Department
I’ve verified that the meta is showing up in the user profiles and such fine. Great! However when I try to pull in the current logged in users Location and Department into text fields on another form using [user_meta key=emplloc] (emplloc is the key I assigned to the location field on the registration form) and [user_meta key=empldept] (empldept is the key I assigned to the department field on the registration form) it doesn’t work. Using other dynamic default values like [user_name] and such work and pull in the correct info, but the user_meta short code isn’t pulling anything in (the field is blank when I go to fill in the form).
Where am I screwing up?
Thanks so much for everything… you guys are real life savers and your support is amazing. I am constantly telling people how great your plugin is!!




October 26, 2012 at 7:16 am
Can you please attach a screenshot of the registration settings that are creating the user meta in question?
October 26, 2012 at 8:58 am
Of course! Take a look see...
Attachments:


October 26, 2012 at 9:03 am
You need to use [user_meta key="Employee Department"] to retrieve it. The meta key us whatever you insert in the user meta settings.
October 26, 2012 at 9:12 am
I get these errors/problems when I use that:
Attachment:

October 26, 2012 at 9:16 am
What type of field is the drop down showing in the registration form? A regular drop down or a data from entries field? Is that form creating WP posts? Do you have another plugin populating user meta into "Employee Department"?
October 26, 2012 at 10:29 am
The registration drop downs for location and department are data from entries dropdowns. None of the forms are creating posts. No other plugins populating any user meta.
:)
October 26, 2012 at 1:33 pm
Maybe you could make a quick, temporary change to see what value is getting returned? Please go to formidable/pro/classes/helpers/FrmProFieldsHelper.php and go down to 176. Add the line in red right before it. This will output something right in front of the error message you are seeing.
print_r($value);
preg_match_all( "/\[(\d*)\b(.*?)(?:(\/))?\]/s", $value, $matches, PREG_PATTERN_ORDER);
October 26, 2012 at 1:37 pm
The 3 there is the correct ID for the department that my account is associated with.
Attachment:

October 26, 2012 at 1:44 pm
Ok, maybe try a small fix. Please go up a few lines to line 168 and change this:
if(is_array($new_value))
$value = $new_value;
else
$value = str_replace($val, $new_value, $value);
to:
if(is_array($new_value)){ if(count($new_value) === 1) $new_value = reset($new_value); $value = $new_value; }else{ $value = str_replace($val, $new_value, $value); }October 26, 2012 at 1:49 pm
That does return a 3 into the text field now... is there a way to have it give the department name instead of the numerical value?
October 29, 2012 at 2:27 pm
Since you're using a data from entries field there, it would probably be better to add a hidden field set as user meta, and populate that with the name with a bit of custom code in your theme functions.php or a new plugin. Please see this related post.
http://formidablepro.com/help-desk/populating-post-meta-data-with-location-name-instead-of-id/
Topic closed.