The Admin account for drupal get this error when trying to send a message "User is not allowed to write messages".

I am trying to send message using the function:

privatemsg_new_thread(array(user_load(100)), 'The subject', 'The body text'));

It works fine when I'm not logged in as admin.

Comments

berdir’s picture

Status: Active » Postponed (maintainer needs more info)

I can't reproduce this.

print_r(privatemsg_new_thread(array(user_load(1)), 'The subject', 'The body text', array('author' => user_load(1))));
// and
print_r(privatemsg_new_thread(array(user_load(1)), 'The subject', 'The body text'));

results in:

Array
(
    [success] => 1
    [messages] => Array
        (
            [error] => Array
                (
                )

            [warning] => Array
                (
                )
        )
)

And with a non-existing user...

print_r(privatemsg_new_thread(array(user_load(1)), 'The subject', 'The body text', array('author' => user_load(2))));

results in

Array
(
    [success] => 
    [messages] => Array
        (
            [error] => Array
                (
                    [0] => User  is not allowed to write messages
                )

            [warning] => Array
                (
                )

        )

)

Tested with devel.module's execute php code.

Are you using the latest dev version?

berdir’s picture

Status: Postponed (maintainer needs more info) » Fixed

I'm settings this to fixed, as there was no response for several weeks. Feel free to re-open this or create a new issue if you have more questions.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.