Everyone Friends v0.1

Release Notes

This mod is based on the "Be Tom" mod by Zac. I hope this is allowed, I have made it very clear and do not claim any copyrights, I'm just submitting this in the hope it will be useful to others.

I have never made a mod before so it probably does not conform to conventions e.t.c. Apologies if I've done anything incorrectly, feel free to change things further.


The mod works like "Be Tom" but it adds everyone as a friend instead of just one person. I have also added custom code to make it so that the new user also appears on everyone else's friends list.

There is a quick very basic script included which you should run once and then delete before enabling the mod. It removes all friends and then makes everyone a friend with everyone.


Note that before using this mod, you should disable "Be Tom" if you're currently using it. Instructions for setup are included in the zip file. Hope this is of use to someone!

CAUTION: The script that you run before installing the plugin will remove ALL friends, then make everyone a friend of everyone. As this is new and I'm the only person that has tested it, I'd recommend you make a database backup before proceeding.

  • Thanks for posting, tomrice. I am new to developing mods as well, but I am excited about this mod because I was thinking of writing something similar. I haven't had a chance to try it yet, but hope to do so soon. I have one simple question at the moment,

    With this mod installed, can users remove friends?

    Thanks for developing and sharing!

  • Ah great, no problem, feel free to improve on it if you find it useful! It's pretty basic - all it does is adds the newly registered user as a friend to everyone when they sign up, so it doesn't mess with anything else and it is still possible for users to choose to remove someone if they don't want to be friends with them. You can't opt out of the feature on a per-account basis, but you can certainly remove individual friends that you don't want.

  • hey! Thanks for this - i'll try play with it later tonight... i was just about to do this all manually as i'm trying to create a site with a group people to help organize things!

  • hi tomrice - i just installed the mod you created - it works very nicely - thanks so much for creating this!

    now my small group of workmates are all set up as friends and we didn't have to do it manually!

    many thanks!

  • Hi, glad it worked ok and is useful to you, thanks for your feedback! :-)

  • Hi Tomrice - Again thanks! This plugin worked great for me - only thing I am seeing is #4 below.


    1. Once i've run this script and activated the plugin - do I then turn the plugin off? or does it need to be left activated?

    2. Should I remove the files with my sites info in them?

    3. If a new user is added to my site later on - can I run this script again or will this break my site if users that are already friends?

    4. I think this plugin may have broke a core plugin "Messageboard" - When I post on a persons Messageboard in thier profile all of the posts say it's from me so:

    • person A activates "messageboard" widget
    • person A posts "Hello" in their message board
      • messageboard post displays "Person A posted"
    • person B posts "Hi how are you?" in Person A's messageboard
      • messageboard post displays "Person A posted"

    Expect: If Person B posts a message on Person A's messageboard they should be displayed as "Person B"

    I saw that there was an issue in Trac about this but it was fixed - not sure what else I can post here to help you out with this.

    I've tried to move the plugins order too but nothing seems to fix this.

    Thanks! - I didn't really need the messageboard - but would be great if I could use it again.

  • Forgot to mention - the "messageboard" plugin:

    - works perfect on the "messageboard" page

    - only broken in the widget in users profile.

  • Hello,

    Thanks for your feedback. I am not seeing the same issue on my site, the message board seems to be working ok. Did you install any other plugins at the same time? Not sure how it would affect that as all it does is add friends when someone registers, it does not edit any code that runs during normal use. Not saying it definitely isn't this plugin though, you never know! Thanks for pointing it out in any case. Will be interesting to see if anyone else reports the same problem. If it's definitely caused by this I'd be happy to look into it when I get some spare time.

    In reply to your other 3 questions:

    1. Once you've run the script and activated it, you must leave it active for it to continue adding everyone as friends with each other.
    2. You may remove everyonefriends.php if you want to, but you can't remove start.php or it won't work anymore. Ideally it would use the built in Elgg functions to connect to the database instead of asking you to fill in your info, but wasn't sure how to do that as it's my first plugin.
    3. If a new user registers later on, they will be added as friends to everyone else, and everyone will be added as friends to them, you don't need to do anything, as long as the plugin is activated. If anything goes wrong though, you can re-use everyonefriends.php at any time to make everyone friends with each other again.

    Hope this helps :-)

  • pls report if the pluging is correctly running on v. 15.5

    thank you !

  • Hi maxz,

    Assume you meant Elgg 1.5, yep it does work on that.

  • Nicely done! So I only ran into one small bump when installing on 1.5 - the delete/add file, "everyonefriends.php", makes references to two tables in the elgg db that needed to be changed.

    'elggentity_relationships' needed to be changed to 'elgg_entity_relationships' and

    'elggusers_entity' needed to be changed to 'elgg_users_entity' to match the table names.


    Thanks again, and very nice!


  • Hi Corbett,

    Thanks for the comments and the heads up on the table names. Glad you've found this useful. Did you change your table prefix from "elgg" to "elgg_" when you installed elgg? I think it's normally just "elgg", unless I did mine differently, but based on a quick google search to check what they're normally called I don't think I have. You still raise a good point though - if people have used a different table prefix it won't work until you change the table names. Maybe I can get a prefix variable from somewhere in the code and use that. Will consider doing that.

  • Corbett,

    Just realised, not sure if you have done so but you'll need to change them on start.php as well otherwise people will not get added as friends when they register.

  • Great, thanks Tom! I just changed the start.php table names as well. All seems to be working fine. I believe I went with the default, I don't recall changing anything but I certainly may have...and if I'm the onnly one with the issue, I must have changed it. In any event, it was simple for me to adjust for my table names and thanks again.

  • Im so sorry! Im a newb, and still learning php! I seem to be getting an error when i run the php script to make everyone friends (lol the everyonefriends.php) it gives me several different errors depending on what i put for my host. My question is this, could you please tell me in what format should i put the host? for example, in the '' i know i need to put the host (my church website) but is it http://www.example.com or how? im sorry for my ignorance, and thanks in advance! :)

  • If you still have trouble it would be useful to know who your host is so I can find out what it should be for you. For most hosts though you should be able to leave it as the default $host = 'localhost'. You could also copy this info from engine/settings.php (see $CONFIG->dbhost = '' at around line 37)

  • im currently using godaddy as my host, and ive figured out that my database host is different from my godaddy acct (so i dont think localhost will work) I changed it and now im getting a different error entirely: Query failed: Table 'cha0921902244172.elggentity_relationships' doesn't exist please inform admin!

    Does this error mean im getting closer, or am i way off? it sounds from this error that at least its getting into the database, but its not finding the particular line that it needs... 

    Thank you so much for your quick responce! :) i need to have this done by tomorrow, so any help is greatly appreciated! :) and maybe my ignorance will help others in the future :)

  • Either the database name is wrong (cha0921902244172) or the table name needs adjusting as you may have added a prefix to your tables. Perhaps check the table name first in the Godaddy hosting manager -> MySQL, then manage database with phpMyAdmin and check if you need to add something before the table names like yourprefix_elggentity_relationships, or sometimes it is elgg_entity_relationships. If that is the case you will need to adjust the table name in a couple of places on both everyonefriends.php (lines 7, 9 and 13) and everyone_friends/start.php (lines 39 & 42)

  • OMG!!! I FIGURED IT OUT! so exciting! lol and i just noticed what you told me :) lol you were right, the _ was missing, so went in and replaced it! i guess i should have read the error message better! Tomrice, you are awesome!!! THANK YOU SO MUCH FOR YOUR HELP!!!! :)

  • And on another note, if you are using Godaddy, make sure to go to your database area, and check for the host of the database, not your website :)

  • No problem glad you got it figured out and that I was able to help :) Hope you enjoy the plugin

  • It works on v 1.7.8 with the following changes:


    Line 7: $deleteRelationships = "DELETE FROM elgg_entity_relationships WHERE relationship='friend'";

    Line 9: $getFriendsIds = "SELECT guid FROM elgg_users_entity ORDER BY guid DESC";

    Execute this file by invoking this URL in your browser: http://<elggdomain>/everyonefriends.php


    Line 39: $getFriendsIds = "SELECT guid FROM elgg_users_entity ORDER BY guid DESC";

    Line 42: $addToFriends = "INSERT INTO elgg_entity_relationships (guid_one,relationship,guid_two) VALUES";

    Lines 51 through 59 should be inside an IF statement to prevent a new user from being added as his own friend:

        //check that the user does not become his own friend
        if($user !== $BE_TOM_FRIEND_GUID)
          if ($i > 0)
            $addToFriends .= ", (".$BE_TOM_FRIEND_GUID.",'friend',".$user.")";
            $addToFriends .= " (".$BE_TOM_FRIEND_GUID.",'friend',".$user.")";

  • @nohup,

    This is not a version specific issue.  Since administrators can choose an arbitrary prefix for their tables, you need to change that to {$CONFIG->dbprefix}table_name for each table.


  • Category: User admin
  • License: GNU General Public License (GPL) version 2
  • Updated: 2014-11-17
  • Downloads: 2472
  • Recommendations: 5