The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group
undefined function wp_tempnam()
I've implemented the PHP duplicate function. All works fine until I try to duplicate an entry that contains attachements.
I get the following error:
Fatal error: Uncaught Error: Call to undefined function wp_tempnam() in /home/kuyazfjt/public_html/wp-content/plugins/formidable-pro/classes/models/FrmProFileField.php:896
Any ideas?
January 23, 2019 at 7:16 am
wp_tempnam() is a valid WordPress function. Troubleshooting an issue like this has no easy answer and requires a much deeper look than we can provide as community volunteers, but as a guess, an error of this nature suggests that you are calling a WordPress function from outside of WordPress.
Also, I don't know what you mean by "I've implemented the PHP duplicate function." I am assuming you are referring to some sort of custom code or function, is that correct?
I suggest you enable WordPress debug to get a more detailed stack trace, or use a tool like Kint where you can see the results of what is being passed to wp_tempnam() just before it executes.
January 23, 2019 at 7:46 am
Thanks for your reply,
I implemented the duplication php code as shown here:
https://formidableforms.com/knowledgebase/php-examples/#kb-duplicate-an-entry
The full error from debug is:
Fatal error: Uncaught Error: Call to undefined function wp_tempnam() in /home/kuyazfjt/public_html/wp-content/plugins/formidable-pro/classes/models/FrmProFileField.php:896 Stack trace: #0 /home/kuyazfjt/public_html/wp-includes/class-wp-hook.php(286): FrmProFileField::duplicate_files_with_entry(1098, 140, Array) #1 /home/kuyazfjt/public_html/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array) #2 /home/kuyazfjt/public_html/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #3 /home/kuyazfjt/public_html/wp-content/plugins/formidable/classes/models/FrmEntry.php(175): do_action('frm_after_dupli...', 1098, 140, Array) #4 /home/kuyazfjt/public_html/wp-content/plugins/formidable-pro/classes/models/FrmProEntry.php(245): FrmEntry::duplicate('460') #5 /home/kuyazfjt/public_html/wp-includes/class-wp-hook.php(286): FrmProEntry::duplicate_sub_entries(1075, 136, Array) #6 /home/kuyazfjt/public_html/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array) #7 /home/kuyazfjt/public_html/wp-includes/plug in /home/kuyazfjt/public_html/wp-content/plugins/formidable-pro/classes/models/FrmProFileField.php on line 896
I'm currently trying to figure this out but have opened a support ticket too
January 23, 2019 at 8:24 am
What version of Formidable Pro are you using? Line 896 in FrmProFileField.php is a blank line in the latest version (3.05). There's no code there. wp_tempnam() isn't called until line 898.
Make sure that the version numbers of Formidable and Formidable Pro are in sync.
January 24, 2019 at 4:11 am
I updated both Wordpress and Formidable Forms & Formidable Pro to the latest versions.
Fresh Wordpress install
Created a brand new form
Views
Pages
No 3rd party plugins
So i'm running everything on a "clean" setup.
I still get this error, very strange problem.
the wp_tempnam() function is defined in wp-admin/includes/file.php
I wonder if it's some kind of permissions problem. At this point i'm stuck for ideas really. It's a shame as duplicating entries is one of the core features of the form I need to build. For the time being i might simply disable file uploads until I find a solution to this.
January 30, 2019 at 4:08 am
If it helps anyone in the future this is how you solve the issue.
All you need to do is add this code immediately after line 881 (insert it in a new line on its own) of your formidable-pro/classes/models/FrmProFileField.php file:
include_once( ABSPATH . 'wp-admin/includes/file.php' );
Discussion closed.