I was trying to organize an invitation system on my website.

The users create events (node)
and another user can flag (take part) this node if they would like to come.
If the author sets the name of the requester in the field (entity reference - user) invited -
it means that the user is invited.

For the visual information I created 4 blocks.
All of them are seen only on the profile pages of the current logged in user.

I made this using the snippet

global $user;
if (arg(0) == 'user' && $user->uid == arg(1) && is_numeric(arg(1)) && (arg(2) == NULL) )
{
  return TRUE;
}

else {
  return FALSE;
}

In block settings setting this code in "Pages on which this PHP code returns TRUE (experts only)".

These block are:

1. The block "I requested"
The filter is:
1) Relationships
Flags: take_part (by current user)

---

I take only those events that I flagged by flag "take part"

2. The block "They requested"
The filter is:

1) Contextual filters
Content: Author uid
Provide default value
Type: user ID from logged in user

2) Relationships
Flags: take_part (by any user)

---

I take only events created by me and flagged with "take part" by any users.

3. The block "I requested - they accepted" or "Match"
1) Contextual filters
Content: Invited
Provide default value
Type: user ID from logged in user

2) Relationships
Flags: take_part (by current user)

---

I take only events that has my name in the field "invited" and that I checked with flag "take part"

4. The block "They requested - I accepted" or "Match 2"
1) Contextual filters
Content: Author uid
Provide default value
Type: user ID from logged in user

---

I take only events created by me.

The problem
I need to filter the event nodes where match

1) The user flagged the node with flag take part or user whose ID is in the field
(Flag user) User: Name

2) The user whose name is in the field
Content: Invited

I was checking the Contextual filters but as it is a block I can only use the PHP Code for filtering.

If anybody knows what kind of snippet I can use for filtering? Or I anybody knows the better system for organizing the system of invitations inside a drupal website?

Thank you in advance!

Comments

leramulina created an issue.