Buddypress update user avatar image via REST

I finally found a SOLUTION and i want to post it because can be useful for someone! public function update_user_avatar() { global $json_api; if (!$json_api->query->user_id) { $json_api->error(“Missing ‘user_id’ parameter.”); } if (!$json_api->query->image) { $json_api->error(“Missing ‘image’ parameter.”); } $user_id = $json_api->query->user_id; $base64 = $json_api->query->image; $imgdata = base64_decode($base64); $f = finfo_open(); $mime_type = finfo_buffer($f, $imgdata, FILEINFO_MIME_TYPE); $type_file … Read more

How to set the default avatar of buddypress avatar [closed]

As @shanebp said: You can define the default avatar site-wide by using BP_AVATAR_DEFAULT For this you can define the constant(s) BP_AVATAR_DEFAULT and/or BP_AVATAR_DEFAULT_THUMB inside the bp-custom.php as described at the buddypress codex page Customizing BuddyPress Avatars, for example like this: Code: $upload_dir = wp_upload_dir(); $url_default_avatar = $upload_dir[‘baseurl’] . ‘/defaults/buddypress/default-member-avatar.png’; $url_default_avatar_thumb = $upload_dir[‘baseurl’] . ‘/defaults/buddypress/default-member-avatar-thumb.png’; define … Read more

How to properly print a 404 error without redirecton? (i.e. keeping the current URL)

You should be using a filter outside of your template for this: add_filter( ‘template_include’, ‘wpa62226_template_include’, 1, 1 ); function wpa62226_template_include( $template ){ if( is_page( ‘some-page’ ) ) : global $wp_query; $wp_query->set_404(); status_header( 404 ); $template = locate_template( ‘404.php’ ); endif; return $template; } Your code is executed before the template is loaded, so it becomes … Read more

BuddyPress: Conditionally filter directory based on Xprofile Field [closed]

Here is the solution that we discussed on http://buddypress.org/support/topic/filter-members-list-based-on-profile-field/ It is based on http://codex.buddypress.org/developer/bp_user_query/#code-examples class BP_Custom_User_Ids { private $custom_ids = array(); public function __construct() { $this->custom_ids = $this->get_custom_ids(); add_action( ‘bp_pre_user_query_construct’, array( $this, ‘custom_members_query’ ), 1, 1 ); add_filter( ‘bp_get_total_member_count’, array( $this, ‘custom_members_count’ ), 1, 1 ); } private function get_custom_ids() { global $wpdb; //figure out … Read more

WordPress Stripping Colons?

No idea why your colons are getting stripped out. Your original code, or @EAMann’s answer, should both work unless you have some very strange filter going on. But using built-in functions to get permalinks should make your life easier in general than trying to concatenate them yourself. Try this: <a href=”https://wordpress.stackexchange.com/questions/34822/<?php echo get_author_posts_url( $curauth->ID ); … Read more

How to control who can view certain pages in BuddyPress? [closed]

I am new to BuddyPress so I don’t know which functions and variables to use here. Read the codex – for example: http://codex.buddypress.org/developer-docs/the-bp-global/ You could create a function in your theme- functions.php or in bp-custom.php and call it from template files and pass it parameters like allowed_users, etc. Or you code hard-code something like this … Read more