Is it permissible to use a pin on Shabbat? For example, may a woman use a pin to fasten a flower or other decoration to her hat or garment on Shabbat? Similarly, if a button fell from one's garment, or if a hem became detached, may he use a safety pin to hold the two parts of the garment together? At first glance, pinning two materials together might violate the prohibition of "Tofer," which forbids sewing or stitching garments on Shabbat.
The Mishna Berura (commentary by Rabbi Yisrael Meir Kagan, 1839-1933) cites the view of the Korban Netanel (Rabbi Netanel Weil, 1687-1769) that fastening two materials with a pin is forbidden by force of Rabbinic enactment. This position is also cited in the name of the work "Ginat Veradim."
Most other authorities, however, disagree, and maintain that pinning materials is permissible on Shabbat. This was the position taken by the Hazon Ish (Rabbi Abraham Yeshaya Karelitz, 1879-1954). The Ben Ish Hai (Rabbi Yosef Haim of Baghdad, 1833-1909) also ruled leniently, though he maintained that one should not bring the pin through the garment more than twice. Hacham Ovadia Yosef, however, argued that pinning is entirely permissible on Shabbat, since the Torah prohibition of sewing applies only to sewing with a thread, which differs substantially from pinning. Hence, nobody would confuse sewing with pinning, and thus the Sages did not enact a prohibition forbidding pinning materials on Shabbat. According to Hacham Ovadia, then, there is no restriction on the number of times one may bring the pin through the materials.
Summary: The Torah prohibition of sewing on Shabbat refers only to sewing with a thread, and hence one may use a pin to fasten materials together on Shabbat.