For my money/at my table:
Casting the spell on an object does not work.
The Glyph of Warding spell can be cast on either an object or an area. For the object version, only "opening the warded object" is mentioned as a valid trigger. As the question points out, being hit by an arrow or a sword is definitely not the same thing as trying to open an object (heck, the object is trying to open you)!
The area version is less clear, but I think it works at least somewhat.
The Arcane Archer's Imbue Arrow ability, fortunately for would be Glyph-cheese-practitioners, isn't using the object-targeting version of the spell. As a matter of fact, the ability specifically requires that it be used with an area spell, and then casts that spell with its area centered wherever the arrow lands.
Here's the relevant text concerning what can trigger a Glyph:
This powerful inscription harms those who enter, pass, or open the warded area or object. A glyph of warding can guard a bridge or passage, ward a portal, trap a chest or box, and so on.
You set the conditions of the ward. Typically, any creature entering the warded area or opening the warded object without speaking a password (which you set when casting the spell) is subject to the magic it stores. Alternatively or in addition to a password trigger, glyphs can be set according to physical characteristics (such as height or weight) or creature type, subtype, or kind. Glyphs can also be set with respect to good, evil, law, or chaos, or to pass those of your religion. They cannot be set according to class, Hit Dice, or level.
I see two possible interpretations here:
- If "You set the conditions of the ward" means that you can have it trigger off of something other than someone trying to enter the warded area, then you can simply set the ward to the creature type of whatever you're shooting at, and it will go off as soon as it lands.
- If that sentence only refers to replacing the password portion of the trigger, then the Glyph won't go off immediately, but will trigger as soon as the target takes any amount of movement, since I would say moving inside the area of a Glyph of Warding constitutes "passing" the ward.
I favor the first interpretation here, because "you set the conditions of the ward" reads like a blanket statement to me, and because it's less clunky to use, but I could definitely see a DM going either way on this.
I would rule that the glyph would still function, as long as you jump into the hole, for the following reasons:
As written, the portable hole creates a space that exists on a
different plane. What this means is that the hole is effectively a
portal to another plane. In this case all that has moved is the
entrance to the plane, and not the plane itself. Given this, the
glyph hasn’t moved at all.
This is an inventive use of a spell and a magical item and as such
the player should be rewarded.
If following the ruling it turned out that it was too powerful, or
that it was in some way breaking the game, it is easy enough to put
a stop to as a DM.
As an example, after a few times of you disappearing into this hole and coming out super buffed, your enemies are going to have heard about your tactics in advance and as soon as you jump in, they will move hell and earth to get to the hole and fold it up with you still inside!
TL;DR
There is no reason that this wouldn’t work. You are placing the glyph on another plane of existence and then moving the entrance to the plane.
Based on a comment from @David Coffron (thank you!), I would add that removing the item that the glyph is cast on is a different matter. In removing the surface on which it the glyph is cast from the hole the glyph would be moved more than 10 feet. The spell specifically says
is moved more than 10 feet from where you cast the spell
I suspect that this is to stop players casting it on an object and then teleporting.
Best Answer
This can work if your DM agrees
Portable Hole says
The opening to the hole is a portal to an extradimensional space. The distance between different planes in general is likely unlimited (although this may be up to your DM, with the possible exception of the border ethereal).
However, the consensus is that treating the distance across the entrance of a portable hole as normal distance is OK. Based on this, you can have spell effects across the entrance target a creature, and the ploy would work, unless your DM rules otherwise.
You do not even have to have them take anything from you. You can just set up the hole with glyphs that carry a trigger like "If a creature I point at is within range, blast that creature". You could snuff out opponents in battle by using your action to open the hole next to them, moving out of blast range if needed, and pointing at the victim.
Like all exploits, while this can be a cool effect the first time you pull it off, it creates long-term balance issues. With enough time and gold, this allows you to turn your portable hole into a deadly bomb (and a single day is all you need). You then can use it over and over to take out key opponents and turn climatic fights into automatic wins. This would force your DM to mitigate, for example by putting heavy time pressure on you, or having someone steal or destroy the hole.
(You do not even have to own a hole, though. You can achieve a similar effect with the Demiplane spell, which does not require you to find a hard to acquire portable hole first).
P.S. In the original form of the question, the object itself was enchanted with the glyph. Taking the object out of the hole would break the glyph because Glyph of Warding says
With this approach the tactic could only work if you can trick them to enter the hole, or take the object right at the rim of the hole bending in. This would cause less exploitable balance issues, because you have to deceive your opponent into cooperating for the method to work.