Invite Friends

Respected Team,

Basically IN current system I could invite my friends and friends can add me..And also If i am trying to invite friend who is already on the system, then it automatically sent friend request..But what i want right now that Couple of friends send me the invitation to my email address xvz@gmail.com and after couple of months i registered to this site via xyz@gmail.com, So as practically i should receive friend request from them in my profile but i am not getting it as of now and i want to do something like this..

Please try to help..

  • Viral,

    I did take a look at the invite code and from what I can tell, the invitation code generated is from an MD5 hash of the user sending the invitation and that of the site secret.  From what I can see, there is no log/record of the invitation other than the email invitation that is sent out.  Therefore, unless code is added to track outgoing invitations, there is no way with the current code to go back and see what invitations have been sent.

    However, it looks like the code to process the invitation include mutual friendship to be made if it is provided although there is no email sent. 

    I think the only thing that need to be added would be to add email notification in the file engine/lib/users.php register_user() function.

            // If $friend_guid has been set, make mutual friends
                if ($friend_guid) {
                    if ($friend_user = get_user($friend_guid)) {
                        if ($invitecode == generate_invite_code($friend_user->username)) {
                            $user->addFriend($friend_guid);
                            if( $friend_user->addFriend($user->guid) ) {

                // generate email
                $emailmsg = sprintf("Your invitation has been accepted and %s has been added as a friend.", $user->name );
                
                notify_user($friend_user->guid, $CONFIG->site->guid, "Your invitation has been accepted", $emailmsg, NULL, 'email');

                            }
                        }
                    }
                }

    Please consider above as a pseudo-code as I did not test it, maybe you can try it out and post back the result here.  Make sure you don't test it on a production site!

  • The current process already sends a message indicating you've been made a friend. This additional message will give you a clue that it is from your invitation because you may not know from the original message it is the friend you invited if they use an alias/username that you may not recognise.  I would change the email message above to include the user's email.

    $emailmsg = sprintf("Your invitation has been accepted and %s (%s) has been added as a friend.", $user->name, $user->email );

    I did test this and it worked for me.

    Note: The proper code should be done as elgg_echo() for the message/subject text in quotes.  the code above is for illustration purpose.

  • Alex..Thanks for your valuable time to spend for me.....Basically i just want to clear the flow, so its not confusing..what i want is when you and couple of other friends sent invitation and  then you register to the site via that same email address where i and others sent you invitation then in your profile you will receive my and others friend request.

    Can you tell me step by step which code i could put in which file, So its not make any problem in whole site....Should i copy this code if you understand the flow then in engine/lib/users.php? Please guide me and i would be really helpful to you...

  • Alex, I copy your code in engine/lib/users.php but once use would register then he/she did not get any friend_request from that invited user...Can you please check for me and even when user would click on that invitation link, its not been automatically friend with other...Thanks again..

    // generate email
                $emailmsg = sprintf("Your invitation has been accepted and %s (%s) has been added as a friend.", $user->name, $user->email );
                
                notify_user($friend_user->guid, $CONFIG->site->guid, "Your invitation has been accepted", $emailmsg, NULL, 'email');
         }
        }
       }

  • Please make sure the invited user clicks on the invitation link that was sent and not just go to the site and register.  Also make sure that the email is indeed working by doing a test with regular registration without an invitation.

    In any case, it is just a step closer to what you wanted.  Something else will need to be developed to track invitations sent by multiple people to the same email address.

  • Ya i am following that and still they are not able to become friends of each other..Even what we want that when ever user directly go to that site and register then also he/she should receive those requests..Because its hard to find that email and search and follow that....I copy your same code..in register_user function..anything missing i am in this code? Can you help me to develop for we can track that invitation and after register it would call friend_request function something like that...Do as much as you can do for me please....

    // generate email 

                $emailmsg = sprintf("Your invitation has been accepted and %s (%s) has been added as a friend.", $user->name, $user->email );
                 
                notify_user($friend_user->guid, $CONFIG->site->guid, "Your invitation has been accepted", $emailmsg, NULL, 'email');
         }
        }
       }

     

  • Please make sure you have the messages plugin enabled and that your are getting messages thru email besides the invitations.

    goto http://lionsclubs.me/demo register and invite a test user which will demonstrate that it works.

    download http://www.knowix.com/demo/users.php.txt and replace your test system engine/lib/users.php

    http://www.knowix.com/demo/userdetails.php.txt should replace your mod/profile/views/default/profile/userdetails.php which will display the user who invited the newly registered friend in their profile.

    You may want to do a diff on the files comparing the new code to the ones being replaced before you use it so you know what code changed.

    I've tried what I can... I really can't help you beyond this.  Good Luck.

  • Please correct my; if I understand the situation correctly;

    "You want to see the friend invitation notifications in your inbox, after you registered to the site. And you want to be added as friend, after you registered to the site"

    Is this what you want?

  • if multiple users are sending invitation to a particular person, and if the person get registered by clicking any of the invitation, he must be the friend of the one who send that invitation he clicked and he must recieve add request from all others who send invitaion

    this is his requirement

  • Da Man wants tracking via email addresses
    vis ==>
    " Suppose User A, B and C sent the invitation
    to the same email address to the same user D
    and after sometimes user D register to the website via same email
    where he/she received all those 3 invitations..
    Once User D register to the website directly going to that site and then login
    He/She should receive those 3 Friend requests in his/her profile..
    And also when user D clicks on that invitation links of User A then
    both A and D automatically be friends of each other. "

    Q ?
    who gonna code this for him ?
    Alec mi a amigo already coded 70% already lolz..