Have been using a drupal site for 10 years, first time I've ever asked a question here, though I have benefited greatly from reading the forum, so thank you!
I use rules for many things but especially sending emails to myself/admins about important things regarding actions done by users.
I need to create a rule that sends me an email for when a user creates a specific piece of content for the first time ever, meaning basically the user is new and this is the first time the user has authored or created the content.
We have only one product(content) on our site that a customer can create, the customer has to create the content first from their accounts, then we make some modifications to it before they can add it to their cart and pay for it.
So, I need the rule to send the email upon creation of the content AND only when the content is the very first one that the user has created.
I can't quite figure out how to parse this out within rules. I've set up plenty of emails in rules before, but they're all pretty basic actions and conditions.
Comments
Comment #2
tr commentedThis is not so much a Rules question - it's more of a high-level question about how to design a data model that stores the data you need and makes it accessible. In order to accomplish this, you need to have a record of which users have created content. While it's possible to easily find that out using the Drupal API directly, that requires programming and a potentially expensive database query that would be specific to your site and not of general use - there is no RulesAction for that, nor should there be. But if you wanted you could create a special action for your site.
Instead, IMO it's more productive to keep track of this as part of the user object by adding a boolean field to the user object indicating whether the user has created content or not. It should be initialized to FALSE when the user account is first created. Then you can write a Rule which is triggered on content creation and checks this user field before sending an email - if the field is FALSE then Rules knows this is the first time that user has created content, so your Rule could then set the field to TRUE and send the email. If the field is TRUE, just don't send the email. This way the information about whether the user has created content is attached to the user, and you don't have to query all the content in the database to see if this user has created content before. All this can be done from the UI with Rules, without programming anything.
An alternative way would be to use a Role instead of a field. Users who have created content can be given a special role of "Content creator". Then you can use Rules to check the user's role in a Condition before sending email. Again, this can be done entirely through the UI with no programming. See the solution at https://drupal.stackexchange.com/a/302292/91909 for something similar to what you are trying to do.