Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use case: how to send a message to all users? #245

Open
OnkelTem opened this issue Mar 18, 2019 · 2 comments
Open

Use case: how to send a message to all users? #245

OnkelTem opened this issue Mar 18, 2019 · 2 comments

Comments

@OnkelTem
Copy link

OnkelTem commented Mar 18, 2019

Hey guys. I've discovered message stack 40 minutes ago, installed all the modules and now I'm trying to figure out how to use it. First things first, I need it to notify users about different events.
How to create a message - I already know. But how to send it to all the users?

@jhedstrom
Copy link
Collaborator

If you are using the message_subscribe_ui module, the subscribers are gathered for you when you call

 $subscribers = \Drupal::service('message_subscribe.subscribers');
  $subscribers->sendMessage($node, $message);

They are defined by flags on the content (eg, subscriptions to nodes are one flag, subscriptions to terms another.)

The message_subscribe_email module can be used either as an example (it builds on the message_subscribe_ui module.), or used as-is to achieve subscriptions.

@jhedstrom
Copy link
Collaborator

In your case of wanting to notify all users, you could skip both the message_subscribe_ui and the message_subscribe_email modules and implement your own hook_message_subscribe_get_subscribers to return all users on the site.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants