ACF Pro 5.8.3
I’m using the determine_current_user filter to set the current user. It works fine until I try to retrieve an option with get_field, then I get an out of memory error from WordPress.
Allowed memory size of 134217728 bytes exhausted (tried to allocate 8192 bytes) in
<b>/sites/wordpress.test/wp-includes/class-wp-query.php</b> on line <b>596</b>
<b>Fatal error</b>: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65536 bytes) in
<b>/sites/wordpress.test/wp-includes/functions.php</b> on line <b>3225</b>
So I wrapped the code in a check for the get_field function, and although the function exists the error keeps happening.
If the get_field function exists why can’t the option be retrieved?
add_filter('determine_current_user', 'set_user');
function set_user($user_id)
{
if (function_exists('get_field')) {
$user = get_field('user_id', 'option');
} else {
$user = 0;
}
return $user;
}
So I’ve been retrieving it directly with get_option, which works fine:
$user = get_option('options_user_id');
FYI, it also fails with same error when retrieving the value from a post:
$user = get_field('user_id', 79);