• Resolved jacobfogg

    (@jacobfogg)


    I am getting a php warning showing up in my logs, a simple code tweak will deal with it…

    Invalid argument supplied for foreach()
    /wp-content/plugins/wp-persistent-login-premium/inc/user-count.php:127

    $allowed_roles = get_transient(‘persistent_login_allowed_roles_reference’);
    foreach( $allowed_roles as $key => $value ) {

    In my use case, I have not set any of the allowed roles so the transient hasn’t been set yet. simply wrapping the foreach() in an if(is_array() && count()) will fix the warning.

    if(is_array($allowed_roles) && count($allowed_roles)){
    foreach( $allowed_roles as $key => $value ) {

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author lukeseager

    (@lukeseager)

    Hi there,

    Thanks for letting me know about the issue. I’ll get that patched up and a new release sorted asap.

    Thanks,
    Luke

    Plugin Author lukeseager

    (@lukeseager)

    Hi,

    Just a quick update to let you know that this has been fixed in the latest version of the plugin. I’ll mark this issue as closed now, if there’s anything else, just let me know.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHP Warning – Invalid argument supplied for foreach()’ is closed to new replies.