• I’m using admin-ajax.php for a front-end function. So I used this code to register my PHP function for both admin and non-admin users.

    add_action(‘wp_ajax_nopriv_checkProducts’, ‘checkProducts’);
    add_action(‘wp_ajax_checkProducts’, ‘checkProducts’);

    My checkProducts function runs fine when I’ve logged in, but I get this warning if I’m not logged in.

    <b>Warning</b>: Invalid argument supplied for foreach() in <b>[…]wp-content\plugins\adminimize\adminimize.php</b> on line <b>121</b>

    I tried to suppress the warning using this:
    error_reporting(0);

    But that hasn’t been working, and the warning prohibits further parsing of the AJAX response – which is actually coming through just fine. So I either need to find a way to suppress the warning or fix it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • I’m having the same issue. Did you manage to fix it?

    I assumed there is a plugin activating the warnings so I added

    error_reporting(0);

    in the beginning of theme’s functions.php and it works.

    Thread Starter ElliottW

    (@elliottw)

    I did not fix it, but I tried your work around – putting error_reporting(0); in the themes functions.php file. That did the trick for me as well.

    Thanks for the tip.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Error in adminimize.php, line 121, when using wp_ajax_nopriv’ is closed to new replies.