Support

Account

Home Forums Front-end Issues Updated User field displaying "Loading failed"

Unread

Updated User field displaying "Loading failed"

  • Hi,

    I’ve been using ACF for a little while now and have been really impressed with how easy it has been to customize just about anything I want but this has really stumped me. I’d like to pre-populate a User field type with a user. I have it almost working with this:

    add_filter('acf/load_field/name=user_access',
        function ($field) {
            $selector = 'user_access';
            global $post;
            $params = array(
                'site_url' => site_url(),
                'admin_ajax_url' => admin_url('admin-ajax.php'),
                'post_id' => $post->ID
            );
            $post_id = $params['post_id'];
            $users = get_field('user_field_name', $post_id, false);
            $users[] = 1;
            $field['default_value'] = $users;
            return $field;
        }
    );

    The problem is that when this code is included if I click on the User field it displays “Loading failed” with a red background instead of the expected behavior of displaying the available users that can be added.

Viewing 1 post (of 1 total)

The topic ‘Updated User field displaying "Loading failed"’ is closed to new replies.