Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
Thank you for your wonderful module.
I was hoping for a simple block with 'you have x relationships request pending' with a link to pending requests.
As the message only shows when you login, would prefer something more persistent.
Would most appreciate any reply, and again thank you.
Lilian
Comments
Comment #1
alex.k CreditAttribution: alex.k commentedYou can create a custom block with this PHP code:
When the user has no pending requests, they will not see the block. Hope it works for you.
Comment #2
Liliplanet CreditAttribution: Liliplanet commentedHi Alex,
That works beautifully! thank you so much .. :)
Comment #3
alex.k CreditAttribution: alex.k commentedGreat :)
Comment #5
igorik CreditAttribution: igorik commentedHi Alex,
Is it possible to get number of only pending requests I got from other users?
Now when I use
I got number of pending requests from other users together with my pending requests what I send to others.
This is not really intuitive. I would like to show only number of requests from others what want to be friends with me and notice user about this (if this number is different from zero).
maybe it could be new value for approved param, e.g. -1: 'approved'->-1
thanks for the help
Igor
Comment #6
birchy82 CreditAttribution: birchy82 commentedAlso I made a view to show a small tab that they have a pending relationship request. Works great. So there is 2 options now!
Comment #7
steve.day CreditAttribution: steve.day commentedI just had the same requirement as #5 and solved it with the following code:
It's a bit more long-winded, but it seems to work.
Comment #8
Anonymous (not verified) CreditAttribution: Anonymous commentedI've packaged the solution from #7 into this static cached function for Drupal 7:
Comment #9
Liliplanet CreditAttribution: Liliplanet commentedHi,
I was wondering is it perhaps possible that the menu item or link show 'relationship requests (x)'
Something similar to when you have a private message which shows 'messages (x)'
Looking forward to any reply, and thank you.
Comment #10
mrf CreditAttribution: mrf commentedComment #11
Maks CreditAttribution: Maks commentedHi,
I totally agree with the Liliplanet (#9)! That would be great!
Comment #12
tanmayk@Liliplanet @Maks
You can create your custom menu for that purpose, same like in privatemsg module.
In your hook_menu, you can specify 'title callback'.
Hope that helps.
Regards,
Tanmay
Comment #13
warmth CreditAttribution: warmth commented@morning_time I'm getting:
Warning: Invalid argument supplied for foreach() in MYMOD_count_pending_relationships()
@Liliplanet & @Maks as @tanmayk said:
Following Drupal Commerce: Alter 'Checkout' link in user menu & Display number of pending messages and friend request on the user menu:
YOURCUSTOMMOD.module
template.php
Note: Remember to clean the cache!
Update: Edited to add @tanmayk's suggestion. #15
Comment #14
warmth CreditAttribution: warmth commentedPossible duplicates: #1022838: counter for total number of requests and approved relationships & #472000: How to check for pending relationship requests
Comment #15
tanmayk@warmth You should check whether you are getting an array and it is not empty ;)
Comment #16
warmth CreditAttribution: warmth commented@tanmayk roger that, thank you!
Comment #17
TazimHossain CreditAttribution: TazimHossain commentedI follow this instruction, but not working for me in my drupal 7.22.
I am new in creating module. whats my wrong?
I doing that...
1. Create a example.info
2. Create a example.module
in example.module add this code
and in my themes bottom of the template.php file
but nothing change in my user menus "My Relationships" menu.
when i check "Messages" and "My Relationships" menu with firebug, i see
"<span class="count green"></span>"
this, in bottom of the menu links.then enable the module and clean all cache.
what i'll do now? please help... waiting for response...
Comment #18
tanmayk@TazimHossain,
If you are seeing "
<span class="count green"></span>
" and not the counter ($count) in there, it seems to me that there is some problem with your if condition. Please check once again whether conditionsif ($name_id == 'mis mensajes')
andif ($name_id == 'mis amigos')
are true.Also no need to change title as 'Not working for me!' ;)
Comment #19
paul_constantine CreditAttribution: paul_constantine commentedCool block.
But you need to change the link from 'relationships/requests' to 'relationships/received' in order for it to work.
Thanks :-)