lewismcarey / User-Field-ACF-Add-on

User Field Add on for Advanced Custom Fields
40 stars 19 forks source link

Cope with deleted users #10

Closed adampope closed 11 years ago

adampope commented 12 years ago

If the user has been deleted since they were selected by ACF then we get a bunch of errors.  This change checks they exist before trying to use them.

Calling code then has to cope with the missing data e.g.

    $users = get_field('users');

    foreach($users as $user){

            if(!isset($user) || $user == null || !is_array($user)){
              continue; // Or print something saying the user has been deleted
            }

            // do something with the user
    }