I want to access to user id in functions.php in custom hook

I’m using “store file uploads for contact form 7” plugin. this plugin returned attachment id by following hook:

function example_callback_id_generated($attachment_id)
{
return attachment_id;
}

add_action('nmr_create_attachment_id_generated', 'example_callback_id_generated', 10, 1);

I want to get current user id in this function to attach file upload to the user by following code:

function example_callback_id_generated($attachment_id)
{
update_user_meta(get_current_user_id(), 'ownership_document', $attachment_id);
}

add_action('nmr_create_attachment_id_generated', 'example_callback_id_generated', 10, 1);

but current user id always is 0

I used get_current_user_id(); in functions.php but I always get 0;

Please help to solve this problem.