Send a personalized email to your users

This query retrieves a list of users, obtains their data (name, email and number of remaining credits, which is stored as meta), and sends a personalized email to each of them.

This query requires the endpoint to have Nested Mutations enabled.

mutation SendPersonalizedEmailToUsers {
users {
credits: metaValue(key: "credits")

# If the user does not have meta entry "credits", use `0` credits
hasNoCreditsEntry: _isNull(value: $__credits)
remainingCredits: _if(condition: $__hasNoCreditsEntry, then: 0, else: $__credits)

emailMessageTemplate: _strConvertMarkdownToHTML(
text: """

Hello %s,

Your have **%s remaining credits** in your account.

Would you like to [buy more](%s)?


emailMessage: _sprintf(
string: $__emailMessageTemplate,
values: [

input: {
to: $__email
subject: "Remaining credits alert"
messageAs: {
html: $__emailMessage
) {
errors {
...on ErrorPayload {

Extensions required for this query permalink

  1. Email Sender permalink

    Send emails via global mutation "_sendEmail".

  2. Field To Input permalink

    Retrieve the value of a field, manipulate it, and input it into another field or directive, all within the same operation.

  3. Helper Function Collection permalink

    Collection of fields providing useful functionality.

  4. PHP Functions via Schema permalink

    Manipulate the field output using standard programming language functions available in PHP.

Bundles containing all extensions required for this query permalink

  1. “All in One Toolbox for WordPress” Bundle permalink

    Achieve all superpowers: All of Gato GraphQL extensions, in a single plugin

  2. “Better WordPress Webhooks” Bundle permalink

    Easily create webhooks to process incoming data from any source or service using advanced tools, directly within the wp-admin

  3. “Private GraphQL Server for WordPress” Bundle permalink

    Use GraphQL to power your application (blocks, themes and plugins), internally fetching data without exposing a public endpoint

  4. “Tailored WordPress Automator” Bundle permalink

    Create workflows to automate tasks (to transform data, automatically caption images, send notifications, and more)

  5. “Unhindered WordPress Email Notifications” Bundle permalink

    Send personalized emails to all your users, and notifications to the admin, without constraints on what data can be added to the email

Tutorial lessons explaining how the query works permalink