Support » Plugin: WPAdverts - Classifieds Plugin » Invalid argument supplied in wpadverts-mal.php 471

  • Resolved ThinkByDesign

    (@thinkbydesign)


    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

    ============================

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    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

    (@thinkbydesign)

    No code that I’ve added. It would have to have come from a plugin, configuration, etc.

    Thread Starter ThinkByDesign

    (@thinkbydesign)

    I should clarify. I’ve not added or modified any of the code – only installed and configured the plugins.

    Thread Starter ThinkByDesign

    (@thinkbydesign)

    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/ – ignore the ssl complaints.)

    Plugin Author Greg Winiarski

    (@gwin)

    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/ in case the form has some private data.

    Thread Starter ThinkByDesign

    (@thinkbydesign)

    Array
    (
    [name] => advert
    [action] =>
    [field] =>
    [form_scheme_id] => 129
    )

    Thread Starter ThinkByDesign

    (@thinkbydesign)

    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

    (@gwin)

    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

    (@thinkbydesign)

    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.