Forum Replies Created
-
function get_my_link ($string, $user_id) { $url = get_home_url(); $user_info = get_userdata($user_id); $name = $user_info->display_name; $link = '<a href =' . $url . '/profiles/' . $name . '>' . $name . '</a>'; return $link; } add_filter ('bp_core_get_userlink', 'get_my_link', 10, 2);
I think I’ve got it, the bp_core_get_userlink function generates the links for all the header action username bits so I filtered that with the above code and seems to be working. Phew, got there in the end! Thanks for the help Henry!
Ah ok, so there isn’t a more generic way to change all the links in the activity feed of the type ‘x joined x’, ‘x posted x’? I’ll have to filter each one separately?
Yes I get that, I think my two initial issues got confused in to one! The second bit of code i’m trying to use to change the profile links is this:
`function _bp_core_get_user_domain($domain) {
$url = get_home_url();
$user_id = bp_get_member_user_id();
if (empty($user_id)) {
$user_id = bp_get_activity_user_id();
}
$user_info = get_userdata($user_id);
$link = $user_info->display_name;
$domain = ” . $url . ‘/profiles/’ . $link . ”;
return $domain;
}
add_filter(‘bp_core_get_user_domain’, ‘_bp_core_get_user_domain’, 10, 4);This works for everything as far as I can see except for the link in the activity feed header where the username is posted ‘admin created the group…’ The link wrapped around ‘admin’ I’m struggling to change.
Great, thank you, that is working well now. I’m also trying to change the link to the user profile and have managed to do it everywhere except in the activity header bit where, with my filter posted above I return just /profiles/ but not the users display name.
So i’ve had some success trying to change the profile links with this code:
function _bp_core_get_user_domain($domain) { $url = get_home_url(); $user_id = bp_get_member_user_id(); if (empty($user_id)) { $user_id = bp_get_activity_user_id(); } if (empty($user_id)) { //$user_id = bp_displayed_user_id(); } $user_info = get_userdata($user_id); $link = $user_info->display_name; $domain = '' . $url . '/profiles/' . $link . ''; return $domain; } add_filter('bp_core_get_user_domain', '_bp_core_get_user_domain', 10, 4); apply_filters( 'bp_get_activity_user_link', '_bp_core_get_user_domain', 15, 1);
This seems to work on every profile link except the one in the activity header section. This link is being changed but just to /profiles/. The display name is not being added to the end… so looking at my code this means i’m not retrieving the user id in the activity. Strangely enough though the user avatar next to the post has the correct link applied to it with the above filter! Any ideas?
My other option is to use the buddypress member profile location but replace it with my profile templates. I tried to implement this by creaing a members/single/home.php in my wordpress custom theme folder… but the profile loads inside another page, i get a page within a page type effect with the username above the inner page… not sure what is going on there? If anyone can help with either of these solutions i’d really appreciate it!
James
I think I have this working now by including get_activity_user_id:
function my_default_avatar_url() { $url = get_site_url(); $user_id = bp_get_member_user_id(); if (empty($user_id)) { $user_id = bp_get_activity_user_id(); } $profile_image = get_the_author_meta( my_avatar, $user_id ); if (empty($profile_image)) { $profile_image = '' . $url . '/wp-content/uploads/avatars/avatar.png'; } return $profile_image; } add_filter( 'bp_core_default_avatar_user', 'my_default_avatar_url' );
Hi, thanks for the heads up, have got fetch avatar no grav disabled now and my filter on bp_core_default_avatar_user is now working! However it is only working for things like members list and and ‘who’s online’ widget. In the activity feed the avatar is always my admin avatar… is there a different filter for avatars fetched during activity feeds?
BEst, James