Answer by Rabbi Chaim Hillel Raskin of Kfar Chabad Beis:
Although min haTorah one may cook and light candles on yom tov for afterwards as long as one could potentially derive benefit from it on that day, Chazal prohibited this and allowed it only on Friday for Shabbos with an eruv tavshilin.
One who isn’t cooking any food for Shabbos is not obligated to make an eruv tavshilin, but heating up food is also considered cooking, and to do so for Shabbos requires an eruv. Furthermore, according to the Alter Rebbe, even lighting Shabbos candles on its own requires an eruv tavshilin with a bracha.
Married children or guests that are eating from the host’s food for Shabbos are considered part of his household and they do not require their own eruv tavshilin to participate in the household’s Shabbos cooking or to light Shabbos candles.
Even if they are sleeping elsewhere, if they are lighting candles by their host’s house, this can be covered. But if they are lighting where they are sleeping, they must make their own eruv.
What if one only realized that he should have made an eruv once it’s too late?
Chazal allowed for a person to make an eruv on behalf of people outside of his household who are unlearned, forgot to make one, were unable to make one (e.g. stuck in traffic), or their eruv was mistakenly eaten. However, one who didn’t bother or forgot5 out of carelessness is not covered.
This eruv can be made to cover everyone who lives in the city (i.e. with regard to techum Shabbos). Thus, one who didn’t realize that he was obligated, may rely on the eruv of someone in that town who made a zikui, (and one should verify that someone made zikui properly).
Published in the Weekly Farbrengen email from Merkaz Anash. Read Sources
How to make an Eruv Tavshilin
Take a plate with one whole matzah and either a piece of cooked fish, cooked meat or a hard-boiled egg on it, (it is a good idea to wrap the matzah/challah and fish, meat or egg in aluminum foil to easily keep them apart from the rest of the foods in your home). Recite the following blessing:
BA-RUCH A-TAH ADO-NAI E-LO-HE-NU ME-LECH HA-OLAM ASHER KID-E-SHA-NU BE-MITZ-VO-TAV VETZI-VA-NU AL MITZVAT ERUV.
Then recite: “By virtue of this Eruv, we (the members of this household), shall be permitted to cook, bake, keep food warm, carry, light candles and do all preparations on Yom Tov for Shabbat.”
Put the foods you used for the Eruv away, and eat them on Shabbat. NOTE: The Eruv Tavshilin allows you to cook on Friday only for Shabbat, it does not allow you to cook from one day of the holiday to the next (ie: Thursday for Friday). It is permissible to cook only from a pre-existent flame, one that was lit before the onset of the Holiday on Thursday before sunset.