Title: Invalid argument supplied in wpadverts-mal.php 471
Last modified: February 23, 2017

---

# Invalid argument supplied in wpadverts-mal.php 471

 *  Resolved [ThinkByDesign](https://wordpress.org/support/users/thinkbydesign/)
 * (@thinkbydesign)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/invalid-2/)
 * My server is running php7.0 with the latest version of the Divi theme, and I’ve
   disabled most plugins except ithemes security and w3 Total Cache (and the ones
   used by wpadverts).
 * I’ve recently installed wpadverts and I’m still new to it, but I have created
   a number of categories and two locations (previous solution I saw said there 
   was a problem when there were no categories/locations).
 * I’m trying to create my first ad on the site, but when I do so I’m seeing the
   following error:
 * Warning: Invalid argument supplied for foreach() in /<path to wordpress>/wp-content/
   plugins/wpadverts-mal/wpadverts-mal.php on line 471
    ===Snippet from that file
   === function wpadverts_mal_form_load( $form ) {
 *  if( $form[“name”] != “advert” ) {
    return $form; }
 * ==> foreach($form[“field”] as $i => $field) {
    =======Call Stack========== # 
   Time Memory Function Location 1 0.0002 366152 {main}( ) …/index.php:0 2 0.0003
   366440 require( ‘/var/www/dailyadsonline.com/wordpress/wp-blog-header.php’ ) …/
   index.php:17 3 0.9927 13308848 require_once( ‘/var/www/dailyadsonline.com/wordpress/
   wp-includes/template-loader.php’ ) …/wp-blog-header.php:19 4 1.0343 13349936 
   include( ‘/var/www/dailyadsonline.com/wordpress/wp-content/themes/Divi/page.php’)…/
   template-loader.php:74 5 1.3251 13629040 the_content( ) …/page.php:45 6 1.3257
   13629288 apply_filters( ) …/post-template.php:240 7 1.3257 13629688 WP_Hook->
   apply_filters( ) …/plugin.php:203 8 1.3267 13632416 do_shortcode( ) …/class-wp-
   hook.php:298 9 1.3268 13646984 preg_replace_callback ( ) …/shortcodes.php:223
   10 1.3269 13647960 do_shortcode_tag( ) …/shortcodes.php:223 11 1.3269 13648432
   ET_Builder_Element->_shortcode_callback( ) …/shortcodes.php:345 12 1.3277 13657104
   ET_Builder_Section->shortcode_callback( ) …/class-et-builder-element.php:439 
   13 1.3278 13657904 do_shortcode( ) …/main-structure-elements.php:913 14 1.3279
   13672296 preg_replace_callback ( ) …/shortcodes.php:223 15 1.3279 13673176 do_shortcode_tag()…/
   shortcodes.php:223 16 1.3279 13673648 ET_Builder_Element->_shortcode_callback()…/
   shortcodes.php:345 17 1.3289 13681928 ET_Builder_Row->shortcode_callback( ) …/
   class-et-builder-element.php:439 18 1.3290 13696312 do_shortcode( ) …/main-structure-
   elements.php:1954 19 1.3291 13710560 preg_replace_callback ( ) …/shortcodes.php:
   223 20 1.3291 13711336 do_shortcode_tag( ) …/shortcodes.php:223 21 1.3292 13711800
   ET_Builder_Element->_shortcode_callback( ) …/shortcodes.php:345 22 1.3294 13713136
   ET_Builder_Column->shortcode_callback( ) …/class-et-builder-element.php:439 23
   1.3294 13713624 do_shortcode( ) …/main-structure-elements.php:2835 24 1.3300 
   13727760 preg_replace_callback ( ) …/shortcodes.php:223 25 1.3300 13728456 do_shortcode_tag()…/
   shortcodes.php:223 26 1.3300 13728928 ET_Builder_Element->_shortcode_callback()…/
   shortcodes.php:345 27 1.3304 13730312 do_shortcode( ) …/class-et-builder-element.
   php:423 28 1.3305 13744200 preg_replace_callback ( ) …/shortcodes.php:223 29 
   1.3305 13744816 do_shortcode_tag( ) …/shortcodes.php:223 30 1.3305 13744816 shortcode_adverts_add()…/
   shortcodes.php:345 31 1.3392 13748272 Adverts_Form->__construct( ) …/shortcodes.
   php:194 32 1.3392 13748272 Adverts_Form->load( ) …/class-form.php:28 33 1.3392
   13748272 apply_filters( ) …/class-form.php:70 34 1.3392 13748672 WP_Hook->apply_filters()…/
   plugin.php:203 35 1.3392 13750576 wpadverts_mal_form_load( ) …/class-wp-hook.
   php:298
 * ============================
    -  This topic was modified 9 years, 3 months ago by [ThinkByDesign](https://wordpress.org/support/users/thinkbydesign/).

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/invalid-2/#post-8843054)
 * Hi, hmm do you have some code snippet which modifies [adverts_add] form? It looks
   like there are just no fields in the form which is causing this warning.
 *  Thread Starter [ThinkByDesign](https://wordpress.org/support/users/thinkbydesign/)
 * (@thinkbydesign)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/invalid-2/#post-8844579)
 * No code that I’ve added. It would have to have come from a plugin, configuration,
   etc.
 *  Thread Starter [ThinkByDesign](https://wordpress.org/support/users/thinkbydesign/)
 * (@thinkbydesign)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/invalid-2/#post-8844587)
 * I should clarify. I’ve not added or modified any of the code – only installed
   and configured the plugins.
 *  Thread Starter [ThinkByDesign](https://wordpress.org/support/users/thinkbydesign/)
 * (@thinkbydesign)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/invalid-2/#post-8844834)
 * I tried disabling all plugins except the one that forces SSL and those for wpadverts,
   but no change. I tried creating a listing through the admin side interface, and
   was able to do that, but when I tried to view it I get invalid foreach argument
   errors in wpadverts-custom-fields.php (see [https://dev.dailyadsonline.com/advert/test/](https://dev.dailyadsonline.com/advert/test/)–
   ignore the ssl complaints.)
 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/invalid-2/#post-8846738)
 * Hmm i am not really sure to be honest, it just looks like the [adverts_add] form
   does not have any fields for some reason.
 * Can you add in wpadverts-mal.php file before
 *     ```
       foreach($form["field"] as $i => $field) {
       ```
   
 * line
 *     ```
       echo "<pre>";
       print_r($form);
       echo "</pre>";
       ```
   
 * refresh the page, then copy and paste the result here, or even better send them
   to me via contact form here [https://wpadverts.com/contact/](https://wpadverts.com/contact/)
   in case the form has some private data.
 *  Thread Starter [ThinkByDesign](https://wordpress.org/support/users/thinkbydesign/)
 * (@thinkbydesign)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/invalid-2/#post-8846853)
 * Array
    ( [name] => advert [action] => [field] => [form_scheme_id] => 129 )
 *  Thread Starter [ThinkByDesign](https://wordpress.org/support/users/thinkbydesign/)
 * (@thinkbydesign)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/invalid-2/#post-8850252)
 * I’ve sent a few messages through your contact form, but haven’t seen any replies
   from you by email. If you’ve not received mine, or have been replying to my messages,
   please let me know on this thread.
 * If you haven’t been … please? Time is a factor.
 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/invalid-2/#post-8851620)
 * Hi, i sent you a reply via email.
 * For anyone else having this problem. It is being caused by Custom Fields add-
   on if you have custom form created for the [adverts_add] form, but the custom
   form was never edited (so basically the scheme is blank).
 * The solution is to either stop using this particular custom form or edit the 
   form from wp-admin / Classifieds / Options / Custom Fields panel and click the“
   Update” button without changing anything so some form structure will be applied
   to the form.
 *  Thread Starter [ThinkByDesign](https://wordpress.org/support/users/thinkbydesign/)
 * (@thinkbydesign)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/invalid-2/#post-8853796)
 * Yep. That’s fixed it!

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Invalid argument supplied in wpadverts-mal.php 471’ is closed to new 
replies.

 * ![](https://ps.w.org/wpadverts/assets/icon-256x256.png?rev=2423472)
 * [WPAdverts - Classifieds Plugin](https://wordpress.org/plugins/wpadverts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wpadverts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wpadverts/)
 * [Active Topics](https://wordpress.org/support/plugin/wpadverts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wpadverts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wpadverts/reviews/)

 * 9 replies
 * 2 participants
 * Last reply from: [ThinkByDesign](https://wordpress.org/support/users/thinkbydesign/)
 * Last activity: [9 years, 3 months ago](https://wordpress.org/support/topic/invalid-2/#post-8853796)
 * Status: resolved