append current user-id to all internal permalinks

You can use the_permalink filter.

function wpse_289182_permalink($url) {
    if(is_user_logged_in())
    {
        return add_query_arg('mref', get_current_user_id(), get_permalink());
    }
    return $url;
}
add_filter('the_permalink', 'wpse_289182_permalink');

techhipbettruvabetnorabahisbahis forumutaraftarium24edueduseduseduseduedusedueduseduedu