Hi, I'm a beginner in php and in elgg.
I can ask the database myself and code in php myself BUT, I do have a problem I'm trying to tweak the friendrequest plugin to only allow friendship between group of people I choosed.
I need to ask elgg for the curent user guid and friend guid. I get functions on the web but I can't make it work :/
I am really beginning in functions, if u could get me the really tiny piece of code wich ask elgg the guid and prompt it in a "$guid_searched" I would be so glad.
Thank u all for your support :)
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
Following methods are used to get user guid you can use of your own need.
Regards
Hi, I didn't get what should I do with these?
For exemple if I wanna use the first
shall I write $guid = elgg_get_logged_in_user_entity()->guid; ?
If you want the guid of the logged in user you can also get it directly with:
$guid = elgg_get_logged_in_guid();
How to retrieve the friend's guid depends on what exactly you are trying to implement, so I can't give you the perfect example. For example
$users_friends = get_user_friends(elgg_get_logged_in_user_guid(), "", false);
would return the user entities of all friends of the currently logged in user.
For reference of Elgg functions you can use http://reference.elgg.org/.
Ok I am trying to disallow friendship between different kind of people, I am thinking about disallowing between guys and girls but I could disallow under 18 years old to make friendship with older people as well.
I am starting from the friendrequest plugin
So Now I can start from the user Id and find if it's a man or a woman.
Now I need to get the id of the one he is trying to be friend with. So I have to find the good area in the add.php to tweak as it must act on two kind of buttons (one in the profil page, on in the member list page)
I'm going to give you the high level overview of what you need to do, then you can dig in and figure out the details:
1. Hook into the 'friending' action
In your hook you can check who is friending who, and if it's not an allowed match register an error message and return false to prevent the action
2. Hook into the 'create', 'friend' event
Same kind of check can be done here too, just in case there are other means of friending happening other than the standard action (from other plugins or whatever)
return false to prevent the relationship from being created
as stated above you can get the currently logged in user guid with elgg_get_logged_in_user_guid();
You can get the potential friend guid with get_input() in the action hook and by checking the relationship guids in relationship event
Docs pertaining to what I'm talking about:
http://docs.elgg.org/wiki/Plugin_Hooks
http://docs.elgg.org/wiki/Events_Overview
Thanks for ur support, but I find it so hard. I didn't get what hook is and my difficulty is to find the place inside the code where the plugin ask for the friend data and ask elgg to make friendship.
here is my add.php
The first lines:
retrieve the user entities of the user who should be friended and the logged in user. So, you have $friend and $user entities to work with, i.e. do your checks if the friending should be allowed or not. You could either add your code that does the check before the following if-clause:
or you could do the check withing the if-clause in the else-part:
The second option of adding the check within the existing if-clause would perform the check only if the other requirements are already met (user entities are available, users are not already friends and there's no former friend request).
the problem is that i added code in order to print the values into the database in a new table
and I found 0 each time so i thought these values are not the one i searched !
i did
i wrote all back
please I need help, when I try to add a friend i find a white page I don't know what's wrong in my code
- Previous
- 1
- 2
- 3
- Next
You must log in to post replies.