In Morocco there is no doubt: strictly forbidden. In Morocco it is even by law forbidden for a moroccan to enter hotelrooms. You will not pass the reception with a guest. And even if you rent a flat sometimes the "gardiens" of the building forbid your guest to enter. You can always try your luck if there is no guard but then beware of "nosy" neighbours.
Tunisia, Algeria, Egypt have about the same hotel policy. Years ago in Egypt it was easy if you took a room in a 5-star hotel with a very busy lobby. Although I was sometimes suprised that there was another "guard" on every floor to check who entered the rooms and now they put up some cameras. When I was with a Tunesian friend in desert oasis he was just 5 minutes in my room for a drink and there was a knock on the door and he had to leave! But in another little hotel in Tunisia there was also a knock on my door at night, and there was a cute bell boy with a fresh bottle of water. It was obvious that here was horny like hell when saw me standing there half naked. Those are the "little adventures" that seem to happen in many Arab countries, often with hotel staff (always horny and bored). Especially in Egypt you come across these guys: camel drivers in the desert, tempel guards, museum guards, horse drivers, shopkeepers...
In Jordan many men gave the special "hidden" handshake, they tickled the palm of your hand with their middle finger...meaning "I like you so let's have some fun if possible" and hotel policy was more loose compared to the Maghreb.
In Bahrain and the Emirates nobody at the reception cares about visitors in your room....you could take a goat up to the room without having a problem :-)). Same goes for Oman and Yemen. No problems with a visitor.