How to notify assigned member if task owner comments.

When a task is created assigned member is getting notification, when assigned member is commenting task owner is getting notification. 

But we task owner writes comments notification is not going to assigned user.

I have to send notification to assigned user when task owner comments. How to do this ?

  • Please only post a question in one thread.  I've deleted all of your duplicate comments on all of the other plugin pages.

  • I am trying this, Please tell me my mistake

     

    if (trim($comment_text) !== "") {

    // If posting the comment was successful, say so
    if ($entity->annotate('generic_comment',$comment_text,$entity->access_id, $_SESSION['guid'])) {
    // print_r($_SESSION['guid']);exit;
    if ($entity->owner_guid != $_SESSION['user']->getGUID())
    notify_user($entity->owner_guid, $_SESSION['user']->getGUID(), elgg_echo('generic_comment:email:subject'),
    sprintf(
    elgg_echo('generic_comment:email:body'),
    $entity->title,
    $_SESSION['user']->name,
    $comment_text,
    $entity->getURL(),
    $_SESSION['user']->name,
    $_SESSION['user']->getURL()
    )
    );

    system_message(elgg_echo("generic_comment:posted"));
    //add to river
    add_to_river('annotation/annotate','comment',$_SESSION['user']->guid,$entity->guid);

    // if ($entity->owner_guid == $_SESSION['user']->getGUID())


    }else {
    register_error(elgg_echo("generic_comment:failure"));
    }
    if ($entity->annotate('generic_comment',$comment_text,$entity->access_id, $_SESSION['guid'])) {

    if ($entity->owner_guid == $_SESSION['user']->getGUID())
    notify_user($entity->assigned_to, $_SESSION['user']->getGUID(), elgg_echo('generic_comment:email:subject'),
    sprintf(
    elgg_echo('generic_comment:email:body'),
    $entity->title,
    $_SESSION['user']->name,
    $comment_text,
    $entity->getURL(),
    $_SESSION['user']->name,
    $_SESSION['user']->getURL()
    )
    );

    system_message(elgg_echo("generic_comment:posted"));
    //add to river
    add_to_river('annotation/annotate','comment',$_SESSION['user']->guid,$entity->guid);

    // if ($entity->owner_guid == $_SESSION['user']->getGUID())


    }else {
    register_error(elgg_echo("generic_comment:failure"));
    }
    }

  • I'm not fully understanding what you are trying to do and what exactly is not working as intented as your English is very difficult to follow (sorry to say that...). When looking at the code I see one thing that seems maybe not as intended though. You have two indendent if-clauses (which might result in two annotations getting created) that check for logged in user != entity->owner and then logged in user = entity->owner. How about this structure:

    if ($entity->annotate('generic_comment',$comment_text,$entity->access_id, $_SESSION['guid'])) {

        if ($entity->owner_guid != elgg_get_logged_in_user_guid()) {

                ...

        } else if ($entity->owner_guid == elgg_get_logged_in_user_guid()) {

                ...

        } else

          register_error(elgg_echo("generic_comment:failure"));

        }
    }

    Maybe restructuring the code this way will also solve the problem you have.

  • sorry, because of my english.

    I, understood what are you trying to tell. But I tried all of this(mrans restructuring the code)

    But I am not able to notify the assigned member when task owner comments .

    Please review my notify function and the if condition to check if task owner comments.

    if ($entity->annotate('generic_comment',$comment_text,$entity->access_id, $_SESSION['guid'])) {

     if ($entity->owner_guid != elgg_get_logged_in_user_guid()) {     

    notify_user($entity->assigned_to, $_SESSION['user']->getGUID(), elgg_echo('generic_comment:email:subject'),

     sprintf(

                    elgg_echo('generic_comment:email:body'),

                    $entity->title,

                    $_SESSION['user']->name,

                    $comment_text, $entity->getURL(),

                    $_SESSION['user']->name,

                    $_SESSION['user']->getURL()

    )

    ); 

    system_message(elgg_echo("generic_comment:posted")); //add to river add_to_river('annotation/annotate','comment',$_SESSION['user']->guid,$entity->guid);           
     }  

     

  • $entity->assigned_to is something I don't know anything about. As I said in your other post assigned_to seems not to be used anywhere in Elgg core. If this attribute is defined and used in your plugin it has to get assigned the correct value before using it within the notify_user() function. This function expects the first parameter to be the GUID of the user that should receive the notification. I don't know what happens in the code before the part you posted or in any other files of this plugin.