Forum Replies Created
-
modification goes here
$retval[] = '/path/to/plugin';
and yes, you have to have structure like thatadd_action('get_template_part_members/single/member-header', 'add_member_header_stack', 10, 2); add_action('bp_locate_template', 'remove_member_header_stack', 10, 6); function add_member_header_stack($slug, $name) { add_filter( 'bp_get_template_stack', 'my_custom_stack' ); } function remove_member_header_stack($located, $template_name, $template_names, $template_locations, $load, $require_once) { if("members/single/member-header.php" == $template_name) { remove_filter( 'bp_get_template_stack', 'my_custom_stack' ); } } function my_custom_stack( $stacks = array() ) { $retval = array(); $retval[] = '/path/to/plugin'; foreach ($stacks as $stack) { $retval[] = $stack; } return $retval; }
This is the best way to do this in my opinion.
Also just adding your stack would work, but I added conditions to only apply this filter when needed and remove after. Not sure how much resource it will save but just tried to be fancy.To understand what this function filter does, I suggest reading this codex
Actually the idea with removing filter came when I was writing this question but still decided to post ^_^
@boonebgorges I have a suggestion for this:
What about not using second query at all.
As long as I can see, this is only used to know if there is more pages and to decide if we need
<li class="load-more"> <a href="#more"><?php _e( 'Load More', 'buddypress' ); ?></a> </li>
So instead of second query we can get
$per_page + 1
activity but return$per_page
and instead of total, return $has_more which is function like this:if(count(activities) < $per_page) $has_more = false; } else { $has_more = true; }
I have used such think with infinite scroll and it works. On the other side I’m not sure about performance but with all my logic, this should be better.
Thanks for great support.
Interesting
The idea came when I was searching for solution and found this
I was implementing
find_in_set
meta query and read the comment below by Willy. Since I don’t want new table for something simple, this sound like a good ideaWordPress allows same key for multiple metas.
Now when I look at that function I think this should allow too, but I want some confirmation before I continue.* @param bool $unique. Optional. Whether to enforce a single metadata value * for the given key. If true, and the object already has a value for * the key, no change will be made. Default: false.
See this link for more information
http://stackoverflow.com/questions/22580088/mysql-search-for-id-in-arrayThis does not answer my question and this is just a way to save array to meta.
The thing I want is to insert multiple metas with the same
key
And question is if its breaks something, if not I can write function myself.Thats not it, I want to add some new sorting:
Where it says All Members, My Friends, My groups.
I want to add new sorting “whats hot”.What you provided is just for recording activity
anyone?
Are you willing to show us your work?
I suggest looking inside Buddypress media
here is already done what you trying to do, so hope it helps
OKay, I followed this guy http://androoha.com/web-design-tuts/80-custom-notifications-buddypress-en
And it did a trick, in some way, so I will extend my question here.
I managed to add function which adds notifications to database when I like an activity.
It displays it well when I have only 1 notification with such component_action.
But when I have to, it just merges my notifications into one, or something like this, sometimes it even brokes (but might be another issue)so here is my code in functions.php
function bp_members_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) { global $bp; switch ( $action ) { case 'new_likes': $thanks_for = $item_id; $who_thanked = $secondary_item_id; $link = '/heregoeslink'; $return = '<a href="'.$link.'">'. $who_thanked .' liked your link!</a>'; break; } return $return; }
I have 5 notifications in database with new_likes component_action and 4 of them belong to current user. so $total_user contains “4”,
now I want to remake this code to display user notifications separatly.
Many thanks even for reading till this )) I also try to continiue thiking for an answer and if something I’ll post it here
Please try to supply answers to the following questions.
1. Which version of WordPress are you running?
Lastest (stable)
2. Did you install WordPress as a directory or subdomain install?
Directory
3. If a directory install, is it in root or in a subdirectory?
Root
4. Did you upgrade from a previous version of WordPress? If so, from which version?
No
5. Was WordPress functioning properly before installing/upgrading BuddyPress (BP)? e.g. permalinks, creating a new post, commenting.
Yes
6. Which version of BP are you running?
Lastest (stable)
7. Did you upgraded from a previous version of BP? If so, from which version?
No
8. Do you have any plugins other than BuddyPress installed and activated? If so, which ones?
Yes, many plugins and all of them BP related, since I don’t have any error/problem with my current installation, I won’t insert here this big list. Need to mantion BP Like/Dislike though
9. Are you using the standard BuddyPress themes or customized themes?
Standart
10. Have you modified the core files in any way?
Yes, In many way 😀
11. Do you have any custom functions in bp-custom.php?
No
12. If running bbPress, which version? Or did your BuddyPress install come with a copy of bbPress built-in?
Lastest, I downloaded it from WP Plugins
13. Please provide a list of any errors in your server’s log files.
Strange but no errors (with Debug turned off)
14. Which company provides your hosting?
Local installation
15. Is your server running Windows, or if Linux; Apache, nginx or something else?
Linux Ubuntu, apache 2.2 php5