You need a way to lock it in.
However is this a one way or 2 way plumbed cylinder? If it's just getting oil on one end, then the other end needs a vent. There are vents that have wire mesh in them to stop thing entering the plug hole or some installers make their own vents by drilling a small hole in the plug. Like grain trucks end dump trailers they only have one way plumbed cylinders. But if the cylinder leaks internal then oil gets on the other side of the cylinder and it must vent somewhere or blow the seal. I have seen guys replace a vent plug with a sealed plug and have problems. My first guess is you are missing a locking clip. New cylinders are not that pricy, if you avoid someone from getting burnt by oil or some one trusting the cylinder and having the bed come down on someone.
If it can not be fixed correctly, I would buy a new one.
Since you are new to hydraulics.
Never ever use galvanized pipe fittings on hydraulic pressure lines. They are not close to being rated for hydraulic pressure. Black iron pipe fittings can be used. But it is best to get regular hydraulic fittings, yes they cost more, but they are rated for hydraulic pressure, not house hold plumbing.
I am an old farmer and I have seen, lots of make shift repairs that scare me. .