I have made custom group members loop on a different URL than members/all-members, inside subpage for single group : https://v3upgrade.local/en/groupes/my-group/students/?mlpage=2
the template is exactly like in members-loop.php, but ajax did not work, and when checking the payload response the result is like so : `scope: all
extras: false
action: students_filter
object: students
filter:
target: #buddypress [data-bp-list]
search_terms: h
page: 1
caller:
template:
method: reset
ajaxload: true( when searching for an item ), for all-members page, the payload is :nonce: 6065e4290b
action: members_filter
object: members
scope: all
filter:
target: #buddypress [data-bp-list]
search_terms: hamza
page: 1
extras: false
caller:
template: group_members
method: reset
ajaxload: true`
can anyone gives any idea how to make exactly like the members-loop , I have 2 pages : students that display users withing the group having the student role, and teachers that display users withing the group having the teacher role, I want both of them to be loaded via ajax so I can preform operation using bp_ajax_querystring ?
Thanks
Hello,
I try for hours to create a function, which will display a small red dot on the nav-bars acitivity stream link, when someone posted something new. Since all users are logged in, it should be possible to work with metadata “last_activity_visit”.
Example screenshot: https://i.imgur.com/eeCvvkj.jpeg
What I tried:
Added below code to themes functions.php. Actually managed to display a red dot, when trying around with the code. But either the dot won’t be displayed at all, or it’s displayed always, even when the user visited the acitivity stream.
function track_activity_page_visit() {
if (bp_is_activity_component()) {
update_user_meta(get_current_user_id(), 'last_activity_visit', current_time('mysql'));
}
}
add_action('wp', 'track_activity_page_visit');
function has_new_activity_posts() {
$last_visit = get_user_meta(get_current_user_id(), 'last_activity_visit', true);
if (empty($last_visit)) {
return false;
}
$args = array(
'date_query' => array(
array(
'after' => $last_visit,
),
),
'max' => 1
);
$activities = bp_activity_get($args);
if (!empty($activities['activities'])) {
return true;
}
return false;
}
function add_red_dot_to_menu_buddypress_activity($items, $args) {
if (is_user_logged_in() && has_new_activity_posts()) {
foreach ($items as &$item) {
if (strpos($item->url, '/activity/') !== false) {
$item->title .= ' <span class="red-dot"></span>';
}
}
}
return $items;
}
add_filter('wp_nav_menu_objects', 'add_red_dot_to_menu_buddypress_activity', 10, 2);
Any clue? 🙂
Three things:
– I can’t replicate the issue you have.
– user_name is not a valid field, btw. It was deprecated.
Using the followwing payload, I actually get this in BuddyPress 14.0 since you are using + in the user_login, that’s not valid.
Request Payload.
curl -X POST "https://bp-demo.test/wp-json/buddypress/v1/signup/" \
-d "context=edit" \
-d "user_email=pratik@testmail.com" \
-d "user_login=testthe+request+" \
-d "password=\"']));L)Q542q8dL3" \
-d "signup_field_data[0][field_id]=1" \
-d "signup_field_data[0][value]=testthe+request+" \
-d "state=gggg" \
-d "country=AZE" \
-d "postal_code=444444" \
-d "mobile_phone=555555555"
{
"code": "bp_rest_signup_validation_failed",
"data": {
"status": 500
},
"message": "Usernames can contain only letters, numbers, ., -, and @"
}
Here is the BP configuration I have locally, taken from my local site: https://bp-demo.test/wp-admin/site-health.php?tab=debug
version: 14.0.0
active_components: Extended Profiles, Settings, Friend Connections, Private Messages, Activity Streams, Notifications, User Groups, Site Directory, Members, Members Invitations
url_parser: BP Rewrites API
global_community_visibility: anyone
template_pack: BuddyPress Nouveau 14.0.0
! hide-loggedout-adminbar: Yes
! bp-disable-account-deletion: Yes
! bp-disable-avatar-uploads: Yes
! bp-disable-cover-image-uploads: Yes
bp-enable-members-invitations: No
bp-enable-membership-requests: No
! bp-disable-profile-sync: Yes
! bp_restrict_group_creation: Yes
! bp-disable-group-avatar-uploads: Yes
! bp-disable-group-cover-image-uploads: Yes
! bp-disable-group-activity-deletions: Yes
! bp-disable-blogforum-comments: No
_bp_enable_heartbeat_refresh: Yes
Hi there,
I’ve customized the members looping template to display users’ full name by combining their first and last names. However, the current BuddyPress filters only support sorting members alphabetically by their display name. Could you please advise on how to modify the BuddyPress filter code to sort members by their first name or last name instead?
Thank you in advance!
This was fixed and will be released as part of BuddyPress 14.1. https://buddypress.trac.wordpress.org/milestone/14.1.0
This is how i did it, and it works as i tested it for my site.
Go to your files:
public_html/wp-content/plugins/buddypress/bp-templates/bp-nouveau/includes
wp-content > plugins > buddypress > bp-templates > bp-nouveau > includes
edit functions.php, go to line 983, or
keyboard find and search for “Registering for this site is easy. Just fill in the fields below, and we’ll get a new account set up for you in no time.”
edit and click save
After checking, I found that the endpoint did not verify user rights at all, and in fact, it did not handle the user_id mentioned in the handbook at all for creating activities.
As a patch, I asked AI to help me generate a plug-in. Anyone who needs it can directly store the following code as a PHP and upload it to the plugins:
Allow administrators to create dynamics for other users through API:
<?php
/**
* Plugin Name: Admin API activity creates privilege
* Description: Allows administrators to create activities on behalf of other users.
* Version: 1.0.4
* Author: Google Gemini Pro
*/
//Allow administrators to create activities on behalf of other users
add_filter( 'bp_rest_activity_create_item_permissions_check', function( $retval, $request ) {
if ( current_user_can( 'manage_options' ) ) {
$retval = true;
}
return $retval;
}, 10, 2 );
//Properly handle the user_id parameter when creating an activity
add_filter( 'bp_activity_before_save', function( $activity_data ) {
//Get request body content
$body = file_get_contents('php://input');
//Parse JSON data
$data = json_decode( $body, true );
//Check whether the user_id parameter exists
if ( isset( $data['user_id'] ) && get_userdata( $data['user_id'] ) ) {
//Modify the user_id property of the $activity_data object
$activity_data->user_id = $data['user_id'];
}
return $activity_data;
} );
Allow administrators to obtain other users ‘XProfiles through API:
<?php
/**
* Plugin Name: BuddyPress Admin API read XProfile privilege
* Description: Allows administrators to read any user's XProfile data regardless of field visibility settings.
* Version: 1.0.0
* Author: Google Gemini Pro
*/
//Allow administrators to read all XProfile data
add_filter( 'bp_rest_xprofile_data_get_item_permissions_check', function( $retval, $request ) {
if ( current_user_can( 'manage_options' ) ) {
//Check whether the field exists
$field = xprofile_get_field( $request->get_param( 'field_id' ) );
if ( $field ) {
//Check whether the user exists
$user = get_userdata( $request->get_param( 'user_id' ) );
if ( $user ) {
$retval = true;
} else {
$retval = new WP_Error(
'bp_rest_member_invalid_id',
__( 'Invalid member ID.', 'buddypress' ),
array( 'status' => 404 )
);
}
} else {
$retval = new WP_Error(
'bp_rest_invalid_id',
__( 'Invalid field ID.', 'buddypress' ),
array( 'status' => 404 )
);
}
}
return $retval;
}, 10, 2 );
I am pretty sure this is a bug, or the API handbook has not been maintained for many years. In the long run, maybe someone should fix these issues in the core program rather than using the temporary plugins I provide.
I’m trying to get the XProfile of the specified user using the API.
My endpoint looks like this:
https://xxxxxxxx/wp-json/buddypress/v1/xprofile/2/data/4
As expected, it will get Fields #2 with user ID 4, which has enforced visibility and visibility level onlyme (adminsonly in the database).
But when I used an authentication with admin privileges to get the endpoint, it returned “Sorry, the profile field value is not viewable for this user.”
After testing,”All Members” is also invalid, only in “Everyone” API can get data properly
The Buddypress version I am using is 14.0
@martenw
Hi there, would you like to open a bug report in trac for this?
https://buddypress.trac.wordpress.org/
I created the CDN for the website wechat.nz:
https://d6476bsmtk1fy.cloudfront.net/
The activities of the member page are correct when loaded for the first time, but the activities loaded after the second time are not the activities of this user.
https://d6476bsmtk1fy.cloudfront.net/members/JuneLee/
The mate of Youzify said that it seems that there is a problem when loading the Ajax of the anti-proxy Buddypress.
Does anybody have any technical suggestions about this?
Thanks.
Best regards
@emaralive @vapvarun thank you for the information, I can try editing and looking into other solutions when I get a chance but this one seems like a warranted challenge for the BuddyPress Programming team.
@thinlizzie it might be a waste of time at this point until the code is revised to take into account other CONSTANTS and the issue with high resolution avatars, cover photos and group profile photos getting discarded after upload. On one hand, that is nice to save server resources, but on the other hand, it’s frustrating because the images look lousy. It cheapens the look of BuddyPress to be honest.
The BuddyPress also needs more design customization options especially the social feed, it’s convenient to have it generate the “Social Feed” page automatically but that is causing me trouble. I’d love to be able to put that Social Feed as a WordPress Widget or in a shortcode to embed on any page template I want. This way, I can customize the background, add a custom title or whatever else I want. BuddyPress has a lot of Widgets available but I want the Social Feed as well with customization options.
@vapvarun I’m not recognizing any of the filters containing resize_args from the posted code snippet, do they ring a bell with you? Also, I think there is some misunderstanding about Avatars and Cover Images, i.e., the process thereof. I’m also thinking instead of all this coding requirement for end users, maybe a configuration screen would help facilitate the setting of the various parameters.
Furthermore, we (BP Team) should revisit this process because it is not possible to regenerate the Avatars or Cover Images because, I believe, the original images are deleted. Thoughts?
@whyknott There are no CONSTANTS specific to Group Avatars; meaning an Avatar is an Avatar, regardless if it is used as a User Avatar or a Group Avatar, they just reside in different directories/folders. Additionally, there are 11 CONSTANTS that are associated with Avatar (if my count is accurate), you may find them in a list, along with other BP related CONSTANTS at the following URL:
BuddyPress Constants
As to setting the “quality” level for when a resize is triggered, I’ll have to get back to you after I confirm that the filter you should be using for resize ‘quality’, does what it should. However, I need to build a tool to grab the resized image before it gets deleted, so that I can verify the ‘quality” level.
To validate file type fields before saving to the database, ensure you are using the correct hook and validation logic. The xprofile_data_before_save hook is intended for profile data in BuddyPress, but your issue might be with the validation function itself. Verify that your validate_required_unshared_fields function is properly defined and hooked. Additionally, check that you are correctly accessing and validating the file type fields within this function. Ensure your function looks something like this:
php
Copy code
function validate_required_unshared_fields($field) {
// Add your validation logic here
if (/* validation fails */) {
// Handle validation failure
}
}
add_action(‘xprofile_data_before_save’, ‘validate_required_unshared_fields’);
Make sure to replace the placeholder comments with your actual validation logic.
Currently, there isn’t any updated documentation regarding Avatar’s. There is some outdated info/documentation which is missing some information and is inaccurate with other information. A goal of the BuddyPress Team (BP) is to make documentation available that is current and accurate. That stated this will be on my TODO list to release documentation regarding Avatars, although what I’m covering here would be considered a “developer” handbook chapter.
In the meantime, there are a number of CONSTANTS that define the size (Width x Height) of various aspects of an Avatar, some of which you already know. There are other parameters that specify the “quality” during a resize and/or cropping process and these processes utilize WordPress to accomplish these tasks.
For example the CONSTANT – BP_AVATAR_ORIGINAL_MAX_WIDTH – default set to 450 – triggers a resize of an uploaded image that exceeds the size defined by this CONSTANT at a “quality” level of 90 (default). In your case, the 610 x 610 image is resized to 450 x 450 at a “quality” level of 90. Assuming defaults for thumb (50) and full (150) the image (450 x 450 @ 90) is cropped based on the cropping boundary box to the sizes for thumb and full at a “quality” level of 82 (default). In this example, your 610 x 610 image has undergone 2 processes that has reduced the “quality” twice.
To mitigate the degradation process, you could set BP_AVATAR_ORIGINAL_MAX_WIDTH equal to or greater than 610. The point being this would be the max width size before triggering a resize. This now leaves the cropping process at a “quality” level of 82, of which, you could mitigate by setting the JPEG “quality” level to something greater than 82 (max would be 100), assuming that you are uploading a jpg/jpeg image. This is defined at the following URL:
jpeg_quality
I’ll assume you know how to create a filter with a callback to return the desired “quality” level. Whether what I’ve outlined will satisfy your requirements for not being “horribly blurry” is yet to be determined because there may be another reason for “horribly blurry” and this just represents another “process of elimination” step/stage.
What I mean is, I’m uploading a perfectly crisp image that is 610×610 pixels in size and BuddyPress optimizes it and/or scales it down to fit the predefined image size, which is fine, however, in the process makes it look bad/blurry. I want the profile images to look better. Plain and simple.
I don’t want the images to be 610×610 because they are profile images but at the same time I don’t want them looking low res. I think if BuddyPress is setting them as ‘thumbnail’ size then it’s using WordPress built-in optimized image which those are typically horribly blurry.
@venutius, yes that does appear to fix it. I guess I was reading the line wrong. This seems like a simple change. I can certainly patch it temporarily, but is there any chance of getting it fixed in the next release?
@espellcaste, actually I’m running different versions of BP on different sites. But I don’t think that file has change recently (it is legacy after all). The exact error depends on what PHP you’re running. Older PHPs give:
Warning: printf(): Too few arguments ... plugins/buddypress/bp-templates/bp-legacy/buddypress/activity/index.php on line 164
Newer PHPs give:
PHP Fatal error: Uncaught ArgumentCountError: 2 arguments are required, 1 given in ... plugins/buddypress/bp-templates/bp-legacy/buddypress/activity/index.php:164
and then a stack trace.
Hi @whyknott,
I’m a bit confused because I’m not sure what you mean by:
I need to change the quality of the images to 100%
Is this in reference to the JPG compression value? Additionally, I find this confusing, as well:
How do I tell BuddyPress to use the full image size and just scale it down to fit the image size vs. using the thumbnail size
As your code snippet indicates, there are 2 (two) image sizes (full & thumb) for Avatars and the default sizes are 50 x 50 for thumb and 150 x 150 for full, both are in pixels. So, if you wish to change the sizes, then you need to change the numeric values to something other than the default values. These are the sizes after a crop of the original image.
To help clarify some things, what is the size (width x height) of the original image that you are using to upload as an Avatar? Let’s start here and see if we can find a solution to your “quality” issue.
Can you share the error and which version of BuddyPress you are using?
I’m having some trouble with line 164 of bp-templates/bp-legacy/buddypress/activity/index.php
I’m getting PHP errors about printf() only getting one argument instead of two. It looks to me like the parentheses aren’t right on that line, but honestly I’m having a little bit of trouble parsing it myself. I would be very grateful if someone more knowledgeable could take a look!
On our buddypress site @mentions work for some but not all our members. However, there doesn’t seem to be a pattern. Sometimes you type @name and it activates a link, sometimes it doesn’t. Sometimes, in the same forum post, one @name works while another does not. I’m advising members to send e-mail notes to people if they want to be sure they see they’ve been @name tagged. Not ideal.
I can’t seem to find anyone else having this issue, so I guess it’s to do with our set-up, but can anyone offer some pointers where I can start to try an fix it?
Thanks,
John
WP version v6.6.1
Buddy Press v14.0.0
Asaros Forums v2.9.0
Pens Around The World
Hello BP-developers,
I also want to thank you for maintaining and developing Buddypress!
We have been using it for almost 10 years and never had issues when updating to a new version.
Passing to 14.0.0 was different. Thanks for the BP Classic that fixes many issues for us but as Lars we still cannot have the translation working yet.
We used to use the buddypress-fr_FR.mo file to change the by default translation of “groupe” (French word for group) in “ExpĂ©” for expĂ©dition on our site. But changing the buddypress-fr_FR and re-uploading to wp-content/languages/plugins as we were used to do at each update, does not seem to work.
Here is a link to our website with both public and registered users : where the blue button close to the title should be “CrĂ©er une ExpĂ©” instead of “CrĂ©er un groupe” and the other blue buttons next to each group “Rejoindre l’ExpĂ©” instead of “Rejoindre le groupe”.
Thanks for your help.
WP 6.6.1
BP 14.0.0
Theme : a minimally customed child version of Boss
This is something I’m working on in the plugin I’m building as a result of this thread: https://buddypress.org/support/topic/disable-rss/
I already have the code to remove stuff from wp search in another plugin I have, I just need to put that into this new plugin and update it specifically for this task.
I should have some code in the next week.
I ask on the troubleshooting forum for a solution to update the old tinymce version with no answers.
TinyMce 4.9 which WordPress and Buddypress implements has security issues and probably won’t be updatet anymore. See this: https://core.trac.wordpress.org/ticket/47218
Would it be possible using the current tiny version from cloud which is 7 by now? This allows admins use the editor further without the danger of beeing hacked. Question to the developers.
At the moment you can’t because of conflicts when using both versions on the same textarea field.