Did you move the database with mysqldump and mysql? Then trigger can fail because he has rights in the old database, and not in the new. The solution is to recreate all triggers. This can be done with the following command.
wp eval "Civi::service('sql_triggers')->rebuild(NULL, FALSE);"
My guess is that you're sending emails out using CiviMail or the "send mail to contacts" search action. This won't pick up the membership ID, because a contact can have multiple memberships and there's no way to know which to use.
I believe at present the only way (in CiviCRM core) to use the membership ID token is when using Scheduled Reminders (*...
There's a feature I wrote for Email API for use with CiviRules called "send email to a related contact". I haven't looked at it recently to see if you can specify "any relationship" as opposed to a specific one, but it should get you most of the way to a solution.