Forum Replies Created
-
Add this before the function
global $bp;It’s just a hack, across various php files
Add a block/unblock button on profile pages
When clicked either add or remove a row from a blocked_users db table via function in bp-custom
Check that table in bp-messages when sending messages & notifications
Check that table in bp-friends when a friend request is madeWorks fine except for the initial “Friendship could not be requested” issue.
So any update can only have one link in it?
I don’t have a function for you, but I’d say you need to count the number of hrefs.
For anything over 1, remove everything between and including the href open and close tags.
Of course, the resulting update may not make sense, english-wise.Got this to work by setting add_filter priority to 12
Remember to also filter on bp_get_activity_latest_update to handle links in member-header
I think this is the right approach, but it’s not working…
In bp-custom –
function add_target_func_callback($matches){ if ( (parse_url($matches[1], PHP_URL_HOST) != 'my.com') && (parse_url($matches[1], PHP_URL_HOST) != 'www.my.com') ){ $matches[0] = 'target="_blank" ' . $matches[0]; } return $matches[0]; } function add_target_blank($content) { $content = preg_replace_callback('#href=['"]([^'"]*)['"]#i', 'add_target_func_callback', $content); return $content; } add_filter('bp_get_activity_content_body', 'add_target_blank', 1, 1 );I’m not sure that $content is being passed to add_target_blank
Simple typo ? Should be:
$username = $bp->loggedin_user->id;
Glad you got it working.
I’d love to see an example of this using an ajax call, about which I know little.
Please post your working example when you get there, thanks.The link just goes to the page that it is on.
That’s what this does: bp_core_redirect( wp_get_referer() ) in bp_send_private_bzzt()So a 404 indicates some other problem that I can’t diagnose, unless…
Did you try putting the code in bp-custom.php, per the instructions, instead of functions.php ?
You have to roll your own.
I got thru it awhile back with help from @r-a-yYou’d have to use action or filter hooks if you put it in bp-custom
Try putting it in a template file, like member-header
My fix –
In bp-xprofile.php
In function xprofile_set_field_dataI changed this line
`if ( $is_required && ( empty( $value ) || !strlen( trim( $value ) ) ) ) { `to
`if ( $is_required && ( empty( $value ) ) ) { `And changes are now saved.
I do not know why the strlen check was causing a problem.I use a version of this on profile pages (member-header.php) – it’s faster than the code in the url above because it only checks one user.
`
function check_is_user_online($user_id){
if ( bp_has_members( ‘type=online&include=’.$user_id) ) return true;
else return false;
}
$this_id = $bp->displayed_user->id;
$is_online = check_is_user_online($this_id);
if ($is_online) echo “NOW ONLINE”;
else bp_last_activity( $this_id );
`Bit of a drag that we have to loop thru all members, but this works and I couldn’t figure out a better way
http://code.hyperspatial.com/all-code/buddypress-code/is-user-online/
The problem lay somewhere in memcache or varnish conditionals
The fix was to comment out this line in wp_includes/registration, function wp_update_user
wp_clear_auth_cookie();I’d use xprofile_get_field_data
Like so:
xprofile_get_field_data(‘your field name’, member_id);I tried Bowe’s method using W3 Total cache and Rackspace CDN (CloudFiles) for a 3 dedicated servers setup – 1 db, 2 frontend.
It failed at the crop avatar step. Everything else was fine.
We had to use NFS instead to sync avatars across the frontend servers – ugh.
Still using W3 Total cache for CDN for other files.@Pisanojm: did MaxCDN allow use of CDN for avatars for you ?
This is all new to me, but I think what is happening is that all file uploads are sent to CDN (Cloud Files). But BP does file operations (copying and creating thumbs, etc), on the file in the uploads dir, but the new files are not uploaded to CDN. The original file is deleted as it should be but on a display call the avatar shown is the default avatar because the call looks in CDN for a file that was never uploaded.
One approach might be to do the operations and then, in bp-core-avatars.php, upload to CDN.
But this isn’t just about avatars, it’s everything in the uploads folder.
So any subsequent operations would require getting the file from CDN rather than uploads, doing operations and then putting it back into the CDN. Not sure if this would work and if it did wouldn’t it waste bandwidth and increase time significantly.Paul – any info you have re avatars to S3 would be appreciated, especially re GD operations on avatars.
The cronjob approach didn’t work either.
So, the basic issue is still trying to keep the uploads folder synced across multiple servers.
If anyone has encountered this, please advise.
Rackspace server support is now suggesting
-local replication with rsync with persistence on the load balancer
or
-NFS (real-time synchronization)We were using a symlink – but it doesn’t support renaming files.
So we went with a every 1 minute cronjob instead.The reason for all this was trying to keep the uploads folder synced across multiple servers.
So image processing will stay on server X, cronjob will pull all files to CDN, and all display calls will be routed to CDN.This can search on custom profile fields
http://www.blogsweek.com/category/bp-profile-search/Thanks for the tip – works here.
Adjustable ~Line 141 in bp-core-classes.php
`
if ( ‘online’ == $type )
$sql = “AND DATE_ADD( um.meta_value, INTERVAL 10 MINUTE ) >= UTC_TIMESTAMP()”;
`Solution
`
function user_nav_add_anchor() {
global $bp;
$bp->bp_nav .= “#your-anchor”;
$bp->bp_nav .= “#your-anchor”;
//etc
}
add_action( ‘wp_head’, ‘user_nav_add_anchor’,9 );
`
Anyone know of a way to do this with a loop through all the $bp->bp_nav[] fields ?Oops – thanks r-a-y.
I chopped down too much the function that I use.
Perhaps this better explains my approach:`
function login_intercepts(){
global $bp_unfiltered_uri;if ( is_user_logged_in() ) {
/* if user logs in at domain name url or logged-out, they are sent to /activity */
if ( ($bp_unfiltered_uri[0] == “”) || ($bp_unfiltered_uri[0] == “logged-out”) ) {
bp_core_redirect( get_option(‘siteurl’).”/activity” );
}/* if user logs in on activate page, they are sent to /welcome */
if ( $bp_unfiltered_uri[0] == “activate” ) {
bp_core_redirect( get_option(‘siteurl’).”/welcome” );
}//etc
}
}add_action( ‘wp’, ‘login_intercepts’, 3 );
`