I made a custom field for users and gave it a default value.
I can view every single user in the WordPress dashboard and see the custom field with the default value.
When I go into the front end of the website and try to call that value (when logged in as a user), the value is blank…
If I open the user in dashboard and just hit save…THEN i can see the default value in the front end…
It looks to be some sort of WordPress database caching issue. I have 1700 users, how can I make the custom field accessible to the front end without opening each of the 1700 users and saving them one at a time?
$theuser = $current_user->id;
$author_credits = get_field('required_credits', 'user_'. $theuser );
How did these default values get added to the database?
when i added the custom field, it gives you an option to give it a default value
Adding a new field when there are existing posts and setting a default value does not retroactively add that value to the old posts. There are several ways of dealing with this, for example this https://support.advancedcustomfields.com/forums/topic/adding-new-field-to-existing-posts/ or this https://www.advancedcustomfields.com/resources/acf-load_value/