Hi guys, i would make a rule for sending an e-mail to a user when someone post a status on his profile.
But i would make it more complex, the rule must evaluate a cck field called status_mail and if it's active a mail is sended to the user who recieve the status.
But i can't accomplish it, because when i select User saves a status i need to apply a condition first
my condition is search inside a node the value of field status_mail turned on ON and next do the action Send a mail to a given user.
But under condition i cant configure nothing related the node i get this
The following conditions aren't available in this context because they require arguments that don't exist in your rule. If you want to use any of these conditions, you must first add some action that adds variables of this kind in a previous rule, or have an event that passes the required variables.
Field has value
Unavailable argument: Content
the same for the action i get this
Send a mail to a user
Unavailable argument: recipient
Someone has an idea how to accomplish this? I think a mail feature can be nice if someone post on your profile like facebook :)
Comments
Comment #1
icecreamyou commentedUse the "load node" action to load the node you want. Then you'll be able to use it in your condition.
Comment #2
GolDRoger commentedThx Ice, you gave me a nice idea.
I started the rule with User saves a status.
Under actions i have selected:
Load the user account, putting in ID the token [status:recipient-id]
Load profile content
Arguments configuration
User, whose profile should be loaded: Loaded user
Content Profile Content Type: User profile
Finished actions I have added a condition: Exegute custom php code
and i inserted this script:
if ('[profile_node:field_uprofile_statusmail-raw]' == 'Send me mails') { return TRUE; } else { return FALSE; }and last step, under action
Send a mail to a user
Arguments configuration
recipient: loaded user
Maybe i'm doing small confusion... This doesn't work actually.
But most strange when i came back to modify the condition Exegute some custom php code, i can see only the token of the status and not like first time (like screenshots).
Sure i'm doing something wrong :/
Comment #3
GolDRoger commentedops made a distraction error. I forgot the php tags included inside Exegute custom php code, wich shouldn't be inculded.
But removing them is the same thing, the rule isn't exeguted and no mail sended
Comment #4
GolDRoger commentedI made a progress, found what's wrong.
Load the user account, putting in ID the token [status:recipient-id]
this was wrong, instead of id I have changed in [status:recipient-name-raw] inside the user name field
and works, but i'm haviing troubles with the cck field [profile_node:field_uprofile_statusmail-raw]
tried to insert the above code inside a Exegute custom php or check a truth value but seems to not work.
:/ I cant understand if the script can't find the token or somewhat...
Comment #5
icecreamyou commentedTry putting
drupal_set_message('[profile_node:field_uprofile_statusmail-raw]');in the place where you have your PHP so you can check that the token has the value you expect.Comment #6
GolDRoger commentedTryied but nothing happens... :( and I'm becoming crazy. It seem he loose the variables.
So it can't recocknize the values. I've used all the week to set up it working with Notifications too but no luck.
Notifications sends me all the mail regarding creation / updating nodes but nothing when a status is created / updated, and i can't undestand why, because i made the subscription to every status ID and on User profile status.
There is a special configuration to do?
I will make a tutorial abiut this but first I have to make it working :)
Comment #7
GolDRoger commentedOk... another update... this post just seems a diary...
Made the correct configuration of Notifications but... When I was closer to accomplih what I will:
Make user choice if recieve or not e-mail notifications on his stream, i found another blocked way.
Notifications has a add on called Notifications Add-On where inside there is the submodule Custom Notifications.
But.... Custom Notificantions don't accept Tokens...
And in your custom notification you can only add a user name where all the new user will auto subscribe. Instead using tokens and auto subscribing a user to own Stream, wich has more sense.
Comment #8
icecreamyou commentedIf you have the Notifications Autosubscribe module installed and users enable auto-subscribing in their profile settings, they will automatically be subscribed to status updates they post or comment on.
Comment #9
GolDRoger commentedThis works for me too Ice, but i can't add the autosubscrption of their user profile status. Now if someone post on my profile I don't get noticed by mail.
For doing this i need to subscribe to my own user profile status. In this case if someone post on my wall i Get the mail notification: user1 posted on Your profile.
But maybe some users don't want to be noticed, that's why i'm trying to' make it working with cck. Just for add option: i will recieve mails or i dont want recieve mails.
Notifications is perfect because an user can set if recieve notifications unlucky i can't add a default subscription with a token for example [status:owner]
So every user Who joins is auto subscribed to own stream and noticed for every user Who post :/
Comment #10
icecreamyou commentedInteresting. I'll see if I have some time to work on this in the next few weeks.
Comment #11
GolDRoger commentedNice :) and thx
By the way i will continue to work parallel to you :)
I'm sure I can grab with the lookup the node id behind the url alias, adding the id to a variabile and call the node load.
And then try to verify if the field status_mail has the value recieve mails and set a return true.
Comment #12
GolDRoger commentedIce I've made it more or less.
Comment #13
GolDRoger commentedWith this script I was going to check the uid inside the url and inserting it in a variable called viewed_user.
Variable passed to $profile_node via content profile load.
In a block this works perfectly when i'm viewing a user profile and returns true.
Inside the rule this doesn't work, so i would use the [status:recipient-id]
but i cant find the variable name.
Is $status->recipient_id ?
Comment #14
GolDRoger commentedOk finally maybe I have understood what is necessary to make this work.
When i start a rule for example : user saves a new status
under conditions I can do only few thisgs because are missing arguments.
The following conditions aren't available in this context because they require arguments that don't exist in your rule.
And that's true, for example I can't load a node to check if some fields have particular values because fbss is not related to nodes.
I have to see if I can make another condition to add at fbss rules for load a content profile using a token for example status:recipient-id.
In this case, loaded the content profile it's possible check cck values at inside
Comment #15
icecreamyou commentedYou can use
drupal_set_message(print_r($variable, TRUE));to print out the structure of a variable. In the case of FBSS the properties of a status object correspond to the columns of the {facebook_status} table in the database so the recipient ID is in the "recipient" property.Also you can probably use the "Load a user" action for a sender/recipient (make sure the recipient is actually a user) and then from there load the Content Profile node associated with it.
Comment #16
GolDRoger commentedDone Ice, nothing happens :/
Loaded user under actions, loaded content profile.
Under actions i can do all the things.
The probelm is conditions. The condition continue to' say true. I can't understand why... It seems to not be albe to find the user id and load the profile...
Comment #17
icecreamyou commentedUnfortunately I can't really help you with that -- it's pretty specific to the CCK field you're working with.
Comment #18
GolDRoger commentedIce, solved. I don't know why but... maybe something in in system table of my db...
I have disabled and uninstalled the Rules module. Enabled another time, made all the experiments and now works... :D
I can't believe i wasted 7 days for this :/
Ok i made a tutorial for this Ice and I have exported my rule so anyone can use it.
I cann add a tutorial child page on book documentation? http://drupal.org/node/1135246
Or If u prefer i can add the tutorial here
Comment #19
icecreamyou commentedNice. Please add it as a child page of the Tips & Tricks page: http://drupal.org/node/1202826
Comment #20
GolDRoger commentedPerfect :) tomorrow morning Ill do :)
Comment #21
icecreamyou commented