Michael

Send private message

You must be logged in to send a private message.

Friends

No friends yet.

Activity

  • Michael posted on Michael's message board
  • Michael replied on the discussion topic How do I find a users GUID in the group General Discussion
    I am trying to implement the plugin be_tom.  It requires that I know the GUID of the person I want to be Tom.  Where can I find the GUID? Thanks
    • so many ways to skin the cat... ;-)

    • Thanks for the info.  I was able to find the GUID but the "be tom" plugin failed to work.  Below is the code I had to modify.  My GUID is "129".  Did I fill in the info correctly?

      <?php

      /* Be Tom - Elgg plugin to automatically add the user you specify as friends with every new user that registers on your site.
       *
       * Instructions:
       * *************
       * 1) Find the GUID for the user you want to be Tom.
       *     If you don't know how a simple way is to look at any of
       *     the action links on their profile and in the link there will
       *     be a part where it says guid=123. 123 is what you want.
       * 2) Put that GUID below in the $friend_guid = 2; line
       * 3) Decide if you want to get emails when people join and become your friend automatically.
       *     By default this is set to not allow the emails to get sent out.
       *     To change it look below for $i_want_emails = false; and make it $i_want_emails = true;
       *
       * And of course check out my Elgg blog for updates, mods, and articles about setting my own Elgg based site up.
       * Blog: http://www.addicted2kicks.com/devblog/
       * Elgg Site: http://www.addicted2kicks.com/
       *
       * Version 1.0 - Zac
       * It's a low priority, but a future todo item will be a page in the admin interface to allow you to
       * configure this plugin easily w/o messing with code. It's a very low priority, but if there is a lot
       * of interest I will start on it.
       */
       
      function betom_init(){
       global $CONFIG;
       register_elgg_event_handler('create', 'user', 'AutoAddFriend',501);
      }

      function AutoAddFriend($event, $object_type, $object){
       global $CONFIG;
       
       $friend_guid = 129; //REPLACE THE GUID # HERE WITH THE ONE YOU WANT!
       
       if($friend = get_entity($friend_guid)) {
        //READ ME: If you want your 'Tom' to receive emails every time someone registers (it'll be the friend added email) then you
        //need to set the below variable to false instead of true.
        $i_want_emails = true;
        
        if(!$i_want_emails) {
         //The engine/lib/relationships.php file would usually catch the friend created event and send an email to our Tom.
         //This will prevent that by removing any hooks that would handle the friend created event.
         //This will also stop any other plugins from interfering with our friend add process (say a friend request plugin)
         if(isset($CONFIG->events['create']['friend'])) {
          $oldEventHander = $CONFIG->events['create']['friend'];
          $CONFIG->events['create']['friend'] = array();   //Removes any event handlers
         }
        }
        
        try {
         $_SESSION['user']->addFriend($friend_guid);
        } catch (Exception $e) {
        }
        
        //If we disabled any events below then reenable them:
        if(!$i_want_emails) {
         if(isset($CONFIG->events['create']['friend'])) {
          $CONFIG->events['create']['friend'] = $oldEventHander;
         }
        }
       }
      }

       

      register_elgg_event_handler('init', 'system', 'betom_init');

      ?>

  • Michael posted on Michael's message board
  • Michael has updated their profile
  • Michael has updated their profile
  • Michael has a new avatar
    Michael
  • Michael has updated their profile