Whilst seeking the reason why a code snippet of mine isn't working, I've set up a fresh test site (multisite) using just Types, CRED, Views & Access plugins. I set up a single post type, a radio field, two single line fields, taxonomy 'County' with values 'England' and 'Bedfordshire' (with England as parent), taxonomy 'Services' with value 'Major'. I created a form for submission by a Guest (create version) containing the fields and taxonomies. With theme 2017 enabled, the form submits without issue. With Astra installed, activated for the Network, enabled for the site and activated at site level, the following entries appear in my debug.log file when the form is submitted:-
[30-Mar-2019 12:58:03 UTC] PHP Warning: urlencode() expects parameter 1 to be string, array given in /home/xxxxxxx/public_html/wp-includes/formatting.php on line 5205
[30-Mar-2019 12:58:03 UTC] PHP Notice: Trying to get property of non-object in /home/xxxxxxx/public_html/wp-content/plugins/cred-frontend-editor/vendor/toolset/toolset-common/user-editors/medium/screen/content-template/frontend.php on line 60
[30-Mar-2019 12:58:03 UTC] PHP Notice: Trying to get property of non-object in /home/xxxxxxx/public_html/wp-includes/general-template.php on line 2795
[30-Mar-2019 12:58:03 UTC] PHP Notice: Trying to get property of non-object in /home/xxxxxxx/public_html/wp-includes/general-template.php on line 2796
[30-Mar-2019 12:58:03 UTC] PHP Notice: Trying to get property of non-object in /home/xxxxxxx/public_html/wp-includes/general-template.php on line 2796
[30-Mar-2019 12:58:03 UTC] PHP Notice: Trying to get property of non-object in /home/xxxxxxx/public_html/wp-includes/general-template.php on line 2796
[30-Mar-2019 12:58:03 UTC] PHP Notice: Trying to get property of non-object in /home/xxxxxxx/public_html/wp-includes/general-template.php on line 2797
[30-Mar-2019 12:58:03 UTC] PHP Notice: Trying to get property of non-object in /home/xxxxxxx/public_html/wp-includes/general-template.php on line 2797
[30-Mar-2019 12:58:03 UTC] PHP Notice: Trying to get property of non-object in /home/xxxxxxx/public_html/wp-includes/general-template.php on line 1539
[30-Mar-2019 12:58:03 UTC] PHP Notice: Trying to get property of non-object in /home/xxxxxxx/public_html/wp-includes/general-template.php on line 1541
[30-Mar-2019 12:58:03 UTC] PHP Notice: Trying to get property of non-object in /home/xxxxxxx/public_html/wp-includes/general-template.php on line 1541
[30-Mar-2019 12:58:03 UTC] PHP Notice: Trying to get property of non-object in /home/xxxxxxx/public_html/wp-content/plugins/wp-views/embedded/inc/views-templates/wpv-template.class.php on line 968
I've looked at the files referenced in the entries and the issue seems to be linked to taxonomies. If I remove the taxonomy fields from the form and keep Astra activated, it submits without issue.
Any suggestions please?
A little update; I've just tried a few other themes to see if the issue is just Astra related but it appears this is not the case.
Of these themes, only 'einfach' works without generating the log entries:-
coherent
blankslate
einfach
OceanWP
plaintext
Simpleasy
I've discovered this morning that actually the errors ARE also being logged when using theme 'einfach' The form submits when using this theme but the errors aren't displayed on the frontend, they're just written to the file. With Astra the form doesn't submit and the errors are displayed on the frontend.
Hi, thanks for the report. After a bit of troubleshooting I was able to replicate this locally and pin down a few more things:
- It seems to require that I select at least one custom taxonomy term in the Form.
- Multisite is not required.
- Access is not required.
- The notices and warnings are logged regardless of the theme, with only Types, Views and Forms active.
- This Form must be placed in a WordPress Archive or added to a WP Archive page some other way for the notices to be generated. The same Form placed in a custom Page will not trigger the same logs.
I'm able to escalate this now to my second tier team for additional investigation, and I'll let you know what I find out.
Hi Christian
Thanks for checking this out & escalating
I only placed the Form on a Page. You're not getting the errors with a Form on a Page???
No, I wasn't able to see the logs produced on a custom Page. Can you take screenshots of the Form settings in wp-admin so I can see your configurations? I may need to update the ticket for my internal team.
Let me know if you need anything else?
Okay the settings look similar to mine, so there must be something else going on. If you can reproduce this on a single site installation, I can work from a Duplicator clone or an export of all your Types, Views and Forms info.
Hi Christian
I've re-created on a single site install, tested that the issue is still present and have export files for Types, Views & Forms ready. Can you enable a private field for a download link please?
Yes here is a private reply field for you to share a download link. Thank you.
Same behavior for me with these exports - the logs are only produced when the test-post_create Form is placed in a WordPress Archive. No logs when the same Form is placed on a custom Page. There could be something else I'm missing. Maybe it has something to do with your URL structure, permalinks and the slug of the page somehow? Maybe certain content on the page or the in the post content template is a factor? I can try working from a Duplicator package next if you'd like, or we can wait and see if the fix for the message in archives resolves the issue for you in pages as well.
Our developers have provided a workaround that should fix this issue in sites that do not use the default permalink structure. The permanent fix for this issue for all permalink structures will not be available soon as it requires a significant amount of work and is not on the current schedule. The workaround solves the issue temporarily until we can address the problem in a more permanent way. Please add the following snippet to a child theme's functions.php file, or create a new snippet in Toolset > Settings > Custom code:
class tssnippet_Support_Submit_Forms_On_Archives {
private $data = null;
private $needs_restore = false;
function __construct() {
$this->maybe_save_postdata();
add_action( 'wp', array( $this, 'maybe_restore_postdata' ) );
}
public function maybe_save_postdata() {
if ( ! get_option( 'permalink_structure' ) ) {
// Note that this will not work on sites with ugly permalinks :-/
return;
}
if (
isset( $_POST['_cred_cred_prefix_form_id'] )
&& isset( $_POST['_cred_cred_prefix_form_count'] )
) {
$this->needs_restore = true;
$this->data = $_POST;
$_POST = array();
}
}
public function maybe_restore_postdata() {
if ( ! $this->needs_restore ) {
return;
}
$_POST = $this->data;
}
}
add_action( 'wp_loaded', 'tssnippet_load_support_submit_forms_on_archives' );
function tssnippet_load_support_submit_forms_on_archives() {
new tssnippet_Support_Submit_Forms_On_Archives();
}
Then test your Form to confirm the logs have stopped. If not, I'll need to work with a clone of your site to see exactly what is happening.
Hi Christian
Have tested this on both single and multi site installs & I can confirm my forms are now submitting and the errors are no longer being generated.
Many thanks for getting this sorted.
FYI the permanent solution for this problem will be included in the upcoming Forms 2.6.10 release. Once you update, the workaround is no longer required.
Forms 2.6.10 is now available.