donmik
Forum Replies Created
-
Forum: Plugins
In reply to: [Buddypress Xprofile Custom Fields Type] Section Breaks/HeadersPlease contact me by email and we can talk about it.
Forum: Plugins
In reply to: [Buddypress Xprofile Custom Fields Type] Add image as profile photoI’m not using a buddypress theme just Twenty Twelve. Sometimes buddypress themes are old and are using old filters, but this is not your case…
I don’t know why this is not working for you. In my test site, I’m using latest versions of buddypress, wordpress and my plugin. I’ve just added this code to the functions.php of my theme:
add_filter( 'bp_core_fetch_avatar', 'my_custom_avatar', 10, 2 ); function my_custom_avatar( $avatar, $params ) { if ( 'user' === $params['object'] ) { // Get the src of the original avatar. $array = array(); preg_match( '/src="([^\"]*)"/i', $avatar, $array ); if ( count( $array ) > 1 ) { $old_url_avatar = $array[1]; // Get the new url of image. $uploads = wp_upload_dir(); $img = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( ID_OF_IMAGE_FIELD, $params['item_id'] ) ); if ( ! empty( $img ) ) { $new_url_avatar = $uploads['baseurl'] . $img; // Replace the old src with the new url. $avatar = str_replace( $old_url_avatar, $new_url_avatar, $avatar ); } } } // Return the avatar. return $avatar; }Maybe you can try to output some values to see if at least your filter is used. Try this:
add_filter( 'bp_core_fetch_avatar', 'my_custom_avatar', 10, 2 ); function my_custom_avatar( $avatar, $params ) { var_dump($avatar); var_dump($params['object']); if ( 'user' === $params['object'] ) { // Get the src of the original avatar. $array = array(); preg_match( '/src="([^\"]*)"/i', $avatar, $array ); var_dump($array); if ( count( $array ) > 1 ) { $old_url_avatar = $array[1]; // Get the new url of image. $uploads = wp_upload_dir(); $img = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( ID_OF_IMAGE_FIELD, $params['item_id'] ) ); var_dump($img); if ( ! empty( $img ) ) { $new_url_avatar = $uploads['baseurl'] . $img; // Replace the old src with the new url. $avatar = str_replace( $old_url_avatar, $new_url_avatar, $avatar ); } } } // Return the avatar. return $avatar; }You should see the content of $avatar variable, $params[´object’] should contain “user”. You should see the content of $array variable and $img.
Please try the new version 2.6 and get back to me if this error isn’t solved.
Forum: Plugins
In reply to: [Buddypress Xprofile Custom Fields Type] Add image as profile photoAre you using a custom buddypress theme? Maybe your theme is using another method to display the avatars. Check the profile page template, it should be this file: buddypress/members/single/profile.php.
Forum: Plugins
In reply to: [Buddypress Xprofile Custom Fields Type] Add image as profile photoMmm, weird, it’s working on my test site. Send me an url or a screenshot to see in which page this is not working.
In my test site, I can see the new photo everywhere now, members list, member’s profile, list of members in sidebar, …
Forum: Plugins
In reply to: [Buddypress Xprofile Custom Fields Type] Add image as profile photoIt seems my code was only working in profile page. Please, replace my old code with this:
add_filter( 'bp_core_fetch_avatar', 'my_custom_avatar', 10, 2 ); function my_custom_avatar( $avatar, $params ) { if ( 'user' === $params['object'] ) { // Get the src of the original avatar. $array = array(); preg_match( '/src="([^\"]*)"/i', $avatar, $array ); if ( count( $array ) > 1 ) { $old_url_avatar = $array[1]; // Get the new url of image. $uploads = wp_upload_dir(); $img = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( ID_OF_IMAGE_FIELD, $params['item_id'] ) ); if ( ! empty( $img ) ) { $new_url_avatar = $uploads['baseurl'] . $img; // Replace the old src with the new url. $avatar = str_replace( $old_url_avatar, $new_url_avatar, $avatar ); } } } // Return the avatar. return $avatar; }In this code, I’m using another filter “bp_core_fetch_avatar” and instead of using “bp_displayed_user_id()” method to retrieve the user id, I’m using $params[‘item_id’]. I’m checking too if $params[‘object’] is “user” because it can be “blog” and “group”.
Try this. Remember to replace “ID_OF_IMAGE_FIELD” with your custom id.
Forum: Plugins
In reply to: [Buddypress Xprofile Custom Fields Type] Change Birthday FormatTo display the age inside the members loop, you cannot use right “bp_member_profile_data”. I will probably modify the result delivered by this method in future updates…
Right now, you will need to use the following code:
echo xprofile_get_field_data('Date of Birth', bp_get_member_user_id());Replace ‘Date of Birth’ with the name or your field or with the ID if you want without the quotes then. “bp_get_member_user_id()” will return the user id inside the members loop if you want to use this method outside the members loop you can use another function to get the user_id like bp_displayed_user_id() for the currently displayed user id or get_current_user_id() for the currently logged in user id.
Forum: Plugins
In reply to: [Buddypress Xprofile Custom Fields Type] Change Birthday FormatWell, using css will not work if you want to support Tab navigation on the form. I’ve been thinking about a better way to add the js without overriding buddypress templates. Add the following code to your theme’s functions.php:
add_action( 'bp_after_profile_edit_content', 'change_birthdate_display_js' ); add_action( 'bp_after_register_page', 'change_birthdate_display_js' ); /** * Change the birthdate field type display: month - day - year. * Uses: * - 'bp_after_profile_edit_content' hook for edit profile form. * - 'bp_after_register_page' hook for registration form. */ function change_birthdate_display_js() { ?> <script> jQuery(function($) { if ($('.bxcft-birthdate-month').length > 0) { $('.bxcft-birthdate-month').each(function() { $(this).insertAfter($(this).parent().find('label')); }); } }); </script> <?php }This code will use 2 hooks:
- bp_after_profile_edit_content: For the edit profile form.
- bp_after_register_page: For the registration form.
I’ve modified my original javascript code because it was working only with one field. If you have more than one birthdate field, you will have problems. This code should work in any case I think.
Forum: Plugins
In reply to: [Buddypress Xprofile Custom Fields Type] Change Birthday FormatYou have to put in your template file overriding buddypress template file.
There is an easier way with css. Maybe it works for you. Add the following code to your theme’s stylesheet:
.bxcft-birthdate-month { float: left; margin-right: 5px; }Forum: Plugins
In reply to: [Buddypress Xprofile Custom Fields Type] Hide (required)Hi,
So I can see you are only using birthdate from my plugin, and this is the only field which is not displaying the required string. This is because the code you added is working.
The rest of your fields are from buddypress plugin, so they don’t work with the code using my plugin’s filter.
Add the following code to your theme’s stylesheet, and hide the required word with some css:
.bp-required-field-label { display: none; }For the field type location, I don’t know what plugin you are using but if this is a plugin you should talk with his author or maybe simply translating the required string to be just a blank space.
Forum: Plugins
In reply to: [Buddypress Xprofile Custom Fields Type] Hide (required)Ummm, maybe your theme is adding the text? It works on my test site.
Send me an url if you can.
Forum: Plugins
In reply to: [Buddypress Xprofile Custom Fields Type] Hide (required)Add this to your functions.php:
add_filter( 'bxcft_field_label', 'my_custom_label' ); function my_custom_label( $label ) { return str_replace( esc_html__( '(required)', 'buddypress' ), '', $label ); }It should remove all required text from labels. This will work only with the field types from my plugin.
Forum: Plugins
In reply to: [Buddypress Xprofile Custom Fields Type] Support for BP 2.7Next version will solve this. Sorry.
Forum: Plugins
In reply to: [Buddypress Xprofile Custom Fields Type] Add image as profile photoHi,
ID_OF_IMAGE_FIELD should be the id not the name. To know the id of your field, go Edit your field from wordpress admin and look at the url:
/wp-admin/users.php?page=bp-profile-setup&group_id=2&field_id=223&mode=edit_field
Here 223 is the id of my field.
Forum: Plugins
In reply to: [Buddypress Xprofile Custom Fields Type] Location (conditional)It’s a request from many users too but there is nothing out there. There is room for a plugin for sure.
Right now, I will use 3 fields using custom post type selector. With some javascript I’m sure you will be able to filter the content of the fields. The problem here will be the performance. Filling the city select will be a long operation…