Put 6 tablespoons butter and the mayonnaise in the bowl of a stand mixer; beat with the paddle attachment until combined, scraping down the sides of the bowl as needed. Set aside.
Spread the macaroni and cheese in an 8-inch-square baking dish to about 3/4 inch thick. Cover with plastic wrap and chill until firm, about 45 minutes. Cut the macaroni and cheese into squares that are slightly smaller than the bread slices.
Meanwhile, melt the remaining 2 tablespoons butter in a skillet over medium heat. Add the onions and cook, stirring, until caramelized, about 20 minutes. Season with salt and pepper.
Combine the barbecue sauce and pulled pork in a saucepan over low heat and cook until warmed through, about 5 minutes.
Generously spread the butter-mayonnaise mixture on one side of each bread slice. Flip over half of the bread slices; layer 1 slice of cheddar, 1 macaroni-and-cheese square and another slice of cheddar on each. Top each with one-quarter of the pulled pork and caramelized onions and another slice of cheddar. Top with the remaining bread slices, buttered-side up.
Heat a large skillet or griddle over medium-low heat. Working in batches, cook the sandwiches until the cheese melts and the bread is golden, about 5 minutes per side.
Photograph by Andrew Mccaul
Recipe courtesy Dave Danhi for Food Network Magazine