Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
privatemsg_message_load() returns a bunch of data about the message, but no recipient_id. So, using privatemsg_message_load() , how do I make sure that the recipient and author of a particular message are the only ones who can view that messsage (without having to query the db specifically for that)? Passing the $account argument doesn't help.
http://api.worldempire.ch/api/privatemsg/privatemsg.module/function/priv...
Thanks
Comments
Comment #1
ptmkenny CreditAttribution: ptmkenny commentedComment #2
work77 CreditAttribution: work77 commentedIs my question dumb in a way I don't realize? Please let me know and I'll change it up. Suggestions anyone?
Comment #3
ptmkenny CreditAttribution: ptmkenny commentedSorry, I'm not an expert on the API, but it might be helpful if you could explain why you want to use privatemsg_message_load()?
Comment #4
ptmkenny CreditAttribution: ptmkenny commentedYou might actually want privatemsg_thread_load(), though there is a bug noted here:
https://drupal.org/node/2033161
Comment #5
work77 CreditAttribution: work77 commentedHi thanks. The reason I want to use privatemsg_message_load() is because I'll be displaying the actual message on my own custom page. The url will contain the message ID, which I was hoping I could simply pass to some function (like privatemsg_message_load()) that would return all of the message info INCLUDING who the intended recipient is. So I could match that up with the current user to determine if she's allowed to view that message.
I notice in the link you provided in the following comment that privatemsg_message_load() is supposed to return false if the user isn't allowed to see it. That kinda would help me, but I was looking for the flexibility to make that decision myself with just getting back all the message info, including the recipient id. Is there another function that can accomplish this?
Comment #6
BerdirThere is no such thing as *the* recipient. Each message can have any number of recipients, there are different types of recipients.
Privatemsg usually only displays and cares about recipients/participants of a message thread, there is AFAIK no API to get the recipients of a single message.
Comment #7
work77 CreditAttribution: work77 commentedThat's what I was referring to by "recipient." privatemsg_message_load() contains everything except WHO can read it, unfortunately. It would be convenient to hook into that info from my module, so I can do with it what I please.
Comment #8
ivnish CreditAttribution: ivnish commented