Support

Account

Home Forums ACF PRO get_field call on user from functions.php is empty

Helping

get_field call on user from functions.php is empty

  • Hello,

    function showUserRights() {
        $user = wp_get_current_user();
         $user_id = $user->ID;
        
        // get the allowed cats from ACF 
         $cat_array =  get_field('allowed_cats', 'user_1', false);
        $cats = implode(",", $cat_arr);
        
        return 'User ID:'.$user_id.'Array:'.$cat_array;
    }
    

    Any idea why the array is empty ? I’ve hardcoded the user_id for testing…
    Best

  • Hi @fountain

    You code looks just fine.

    You need to confirm the field name is correct and also do a var_dump of the cat_array variable to ensure that the correct values are returned.

    Let me know how it goes.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.