Here is the flow process I would like to achieve on my site.
- Anonymous User tries to flag a node
- Anonymous User gets redirected to /user/register page
- Account Gets Created and Flags get associated
- Flagged Node author gets email with new users info
1-3 are working perfectly. I have Rules redirect Anonymous Users anytime a node is flagged to the /user/register page. The user fills out the form and is signed up, and the flag is automatically associated with his account (Thank you Session API+Flags 2!!!). The problem comes in when I try to get a rule to send the node (flagged) author an email all of the profile fields come out blank. I have even tried getting rules to schedule the email so that it gives the user time to signup before trying to send the message.
If a registered user flags content, the node author gets an email that is properly formatted.
Has anyone else tried this? Can someone point me in the right direction?
Thank you so much for reading this.
Chance
Comments
Could be a flag bug
The phenomenon you describe sounds similar to a bug that was in a previous version of Flag, where anonymous flags wrecked havoc with a site when the user logged in or created an account -- all the anonymous flags where then assigned to the user account, but there were some strange side effects that made the flags tagged with user 0 and thus turned global (instead of per-user flags).
Can you verify that the flags actually have sensible data (by listing them in Views or something)?
My guess is that something weird is happening when the flag is transferred from the anonymous user to the user account, that makes the flag lose some data. Perhaps Flag technically removes the anonymous flag and sets a new one for the logged in user. If so, there is no author data to collect, since the flag leading to the node has disappeared.
One way of going around this is to send an email before the user even creates an account. I guess it wouldn't be quite the function you want, but you could still use it for debugging purposes (and hopefully see that you have author information available at some point in the process).
Good luck, anyhow!
//Johan Falk, NodeOne, Sweden
Got it!!
Thank you for the reply, but I went in a different direction and implemented a work-around. I created a secondary "final" flag and wrote a little code to have the first flags converted to the second flag when a user visits /user (the default redirect for all logins on the site). Once the "final" flag is flagged, the emails are created through rules. Everything is working great!.
Here is the code I used on my custom /user pages if you are interested:
<?php$flag_status = flag_get_user_flags('node');
$flag_status2 = $flag_status[request_more_info];
if ($flag_status2) {
foreach ($flag_status2 as $flaged) {
global $user;
$nodeid = $flaged->content_id;
$newflag = flag_get_flag('request_final');
$newflag->flag('flag',$nodeid,$user);
$oldflag = flag_get_flag('request_more_info');
$oldflag->flag('unflag',$nodeid,$user);
}}
?>