WordPress.org

Ready to get started?Download WordPress

Forums

EventPress
Event Invitations (3 posts)

  1. Micah Wood
    Member
    Posted 3 years ago #

    Kunalb,

    Sorry if I am bugging you too much, but there is one other question I have. For any given event, the user has the ability to send invitations out for the event. Currently, all of the members in the directory appear on the 'Send Invites' section. I saw that you are using the get_inviteable_ids() function to put this query together.

    What would be the easiest way for me to limit a user's ability to send invites to just that user's friends? We prefer that users can't invite all the users on the site, as this list is going to be quite large.

    http://wordpress.org/extend/plugins/eventpress/

  2. kunalb
    Member
    Plugin Author

    Posted 3 years ago #

    Easiest would be to override the inviteableids list generated by that function using the filter ep_inviteable_ids. I made a rather complex query to find people who hadn't already been invited, etc. etc. which is captured in get_inviteable_ids (ep/models/registration.php)

  3. Micah Wood
    Member
    Posted 3 years ago #

    For anyone trying to do the same thing, here is the code that I dropped into my theme's function.php file:

    add_filter('ep_inviteable_ids', 'get_just_friends');
    function get_just_friends($data){
      global $wpdb;
      $user_id = get_current_user_id(); // WP Function
      if( !friends_check_user_has_friends($user_id) ) return FALSE;
      $friends = friends_get_friend_user_ids($user_id); // BP Function
      $friend_count = friends_get_total_friend_count($user_id); // BP Function
      $friend_set = NULL;
      $i = 1;
      foreach($friends as $friend){
        $friend_set .= 'ID = '.$friend;
        if( $i != $friend_count ) $friend_set .= ' OR ';
        $i++;
      }
      $query = "SELECT ID, user_email, user_nicename, display_name, display_name AS value FROM ".$wpdb->users." WHERE ".$friend_set;
      $data = $wpdb->get_results($query);
      return $data;
    }

    Thanks for your help on this!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags