Forum Replies Created
-
In reply to: Users creating posts
Also, I will suggest using the above plugin in combination with BuddyBlog for a better experience.
In reply to: Private Pages Glitch?This may be considered as bug in current behavior. Currently, BuddyPress only looks for published pages when looking for component associated pages in bp_core_get_directory_pages().
You may want to report it on the BuddyPress trac and the core developers and weigh their opinions on this.
Hi George,
No, There is no API function to fetch field group id from field group name and you will need to write your own sql query for the purpose.Also, In your example you have passed the profile_group_id to the bp_get_profile_field_data. Please note, it does not take that as a valid argument. It only accepts user_id and field. group id is not required for fetching field data.
Now, If we forget about the group name API and come to the original requirement, Do you plan to fetch the data for multiple users(In loop) or just once/twice.
For fetching data, these two functions work
You can either use
$data = xprofile_get_field_data( $field, $user_id = 0, $multi_format = 'array' )where $field is field id or name( If you know the id, It will fetch from any group, Name has the issue)
or as you specified
$data = bp_get_profile_field_data( array( 'user_id' => $user_id, 'field_id' => $field ) );The xprofile data APIs do not allow passing group in general. You either pass a field id or name.
The problem will happen when multiple fields have same name. In that case, the first field with the name matches if you use the above functions.
Another point, In both the cases, There is no group arguement and if you use field name, that will need one extra query(field id should be preferred if the id is known).
Honestly speaking, It is ok to use it one or 2 time on page but avoid using it inside the loop. If you plan to use it inside the loop, you should try to first fetch the xprofile data and cache and then use any of these functions. One way to cache will be by calling
BP_XProfile_ProfileData::get_value_byid( $field_id, $user_ids )Where $field_id is the id of field(not name) and $user_ids is one or more user ids.
Hope that helps.
In reply to: Number of comments on that entryHi,
You need to override this js functionbp_legacy_theme_hide_comments(There are many ways to do it. You can either put the following code in your theme’s js file
function bp_legacy_theme_hide_comments() { var comments_divs = jq('div.activity-comments'), parent_li, comment_lis, comment_count; var max_show = 2; if ( !comments_divs.length ) { return false; } comments_divs.each( function() { if ( jq(this).children('ul').children('li').length < max_show ) { return; } comments_div = jq(this); parent_li = comments_div.parents('#activity-stream > li'); comment_lis = jq(this).children('ul').children('li'); comment_count = ' '; if ( jq('#' + parent_li.attr('id') + ' a.acomment-reply span').length ) { comment_count = jq('#' + parent_li.attr('id') + ' a.acomment-reply span').html(); } comment_lis.each( function(i) { /* Show the latest 5 root comments */ if ( i < comment_lis.length - max_show ) { jq(this).addClass('hidden'); jq(this).toggle(); if ( !i ) { jq(this).before( '<li class="show-all"><a href="#' + parent_li.attr('id') + '/show-all/" title="' + BP_DTheme.show_all_comments + '">' + BP_DTheme.show_x_comments.replace( '%d', comment_count ) + '</a></li>' ); } } }); }); }or you can put the following php code in your bp-custom.php/functions.php
function buddydev_override_legacy_theme_hide_comments_js() { ?> <script type="text/javascript"> function bp_legacy_theme_hide_comments() { var comments_divs = jq('div.activity-comments'), parent_li, comment_lis, comment_count; var max_show = 2; if ( !comments_divs.length ) { return false; } comments_divs.each( function() { if ( jq(this).children('ul').children('li').length < max_show ) { return; } comments_div = jq(this); parent_li = comments_div.parents('#activity-stream > li'); comment_lis = jq(this).children('ul').children('li'); comment_count = ' '; if ( jq('#' + parent_li.attr('id') + ' a.acomment-reply span').length ) { comment_count = jq('#' + parent_li.attr('id') + ' a.acomment-reply span').html(); } comment_lis.each( function(i) { /* Show the latest 5 root comments */ if ( i < comment_lis.length - max_show ) { jq(this).addClass('hidden'); jq(this).toggle(); if ( !i ) { jq(this).before( '<li class="show-all"><a href="#' + parent_li.attr('id') + '/show-all/" title="' + BP_DTheme.show_all_comments + '">' + BP_DTheme.show_x_comments.replace( '%d', comment_count ) + '</a></li>' ); } } }); }); } </script> <?php } add_action( 'bp_after_activity_loop', 'buddydev_override_legacy_theme_hide_comments_js' );Both will work. you can change the max_show to any value. Hope that helps.
In reply to: The name feild at registrationHi,
Since I got this same question in my email today. Assuming that it was you or a coincidence, I will post the code here as well for everyone else.1. BuddyPress Needs the field_1, so you can not delete it. That gives us a solution, we can hide it using css/js and set it’s value to the value of username.
There are two possible approaches.
The first step is use following in cssdiv.field_1{ display:none; }That will hide the input box on the form.
Now, we can update it using the js or PHP. I will post the simple solution using js
You can put the following code in your bp-custom.php or functions.php
function buddydev_disable_firstname() { ?> <script type="text/javascript"> jQuery(document).ready(function(){ var jq=jQuery; jq("#signup_username").on("blur",function(){ jq("#field_1").val(jq("#signup_username").val()); }); }); </script> <?php } add_action( 'bp_after_register_page', 'buddydev_disable_firstname');That should do it.
There is another pure php solution by settings $_POST[‘field_1’] to the other value but I will leave that for others to figure out 🙂
In reply to: [Resolved] Change the default avatarNo problem. Thank you for confirming 🙂
In reply to: [Resolved] Change the default avatarHi,
No problem. The bbPress encodes the code.It is always better to avoid the code in email and copy paste from forum itself.Is the issue fixed now?
In reply to: [Resolved] Change the default avatarHi,
sorry about the trouble. Please make sure that you put that line in php block. Either before the closing ‘?>’ or after the ‘<?php’ tag.In reply to: [Resolved] Change the default avatarFor that purpose, please put the following line too in your bp-custom.php
add_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' );That forces BuddyPress to avoid using gravatar and use local avatars for default(when no avatar is uploaded).
Hope that helps
No problem. Glad to help 🙂
In reply to: Dynamically populate xprofile select boxHi Daryll,
Your best bet is creating a new xprofile field type and extend select filed type.It is a code I had written around a year ago for some client, but this may point you into the direction. It is for country list.
https://gist.github.com/sbrajesh/5b3f4fd44c9c91b3ed3e
All you need to do is extend the select field and override 3 methods
is_valid(),
display_filter()
and edit_field_options_html()I did a little more as I wanted the same field type to allow single/multi selection both.
Hope that helps.
Hi @buckybeever,
You need to change one linechange this
'show_for_displayed_user' => true,to this
'show_for_displayed_user' => bp_is_my_profile() || is_super_admin(),That will do it. Hope it helps.
Sorry if I am late here.
I just tested the plugin today with BuddyPress 2.2.3.1 and It is working. I have updated a new version too that cleans it a little bit.Hope that helps.
Hi,
Is your theme BuddyPress compatible, if yes, Please check if there is ‘members/single/member-header.php or buddypress/members/single/member-header.phpIf yes, you can put the code anywhere in that file. If your theme does not have this file, It can be added via ‘bp_member_header_actions’ too like this
add_action('bp_member_header_actions', 'devb_show_displayed_user_email' );which you can put in the bp-custom.php too.
In reply to: NotificationHi Christian,
no problem. If you decide to not use it again, you can use my plugin BuddyPress notification widget in that case.About the notice plugin,
I will write the code tonight and put on github and link here.
Thanks
BrajeshIn reply to: NotificationHi Christian,
in case of limited no. of trusted users, we can add the capability ‘bp_moderate’. Still, I will say it is a flawed approach and insecure. Please do not try that.Can you please let me the answers of the following questions and may be I can put some code:-
1. By notice, do you want to show the users who created this notice?
2. I assume there can be more than one notice at a time?
3. Should all users be mailed on notice(also a local notification be generated for each user)
4. Is there anything else you want to be part of this notice feature?Thanks
In reply to: NotificationHi Christian,
If you want to allow it for all users using the inbuilt notice my not be the best option as it needs bp_moderate capability and I will strongly recommend against giving everyone the ‘bp_moderate’ capability.If you are comfortable with the code, I will suggest look at the bp-messages component and check now the notices are handled. With some slight modification, you can achieve the same.
In reply to: Activity Stream Homepage Compatibility IssuesHi,
You are right about creating a home.php or front-page file and putting the content from activity/index.phpHere are a couple of things that I may suggest to improve it.
Since you are using the code (which is part of bp-legacy template and most theme include that), you activity/index.php does not have header/footer.
The easy way is.
1. copy the page.php from your theme and rename it to home.php
2. Now look for the section where you see the loop code( something like while(have_posts()) ..etc, replace only that section of code with the the content of actvity/index.php or you can put this line<?php bp_get_template_part( 'activity/index' ); ?>It will include the activity loop inside your home page.
You may want to look for the div/classes that is generated for your post. If you can inject that, it should look fine(as your theme supports bp and they should have the css.
If it does not work, please post the content of your homepage on pastebin and I will modify it for you 🙂
In reply to: NotificationHi Christian,
There is one functionality in BuddyPress that allows it. You can see the feature as site wide notice(Mark a message as notice).The problem is currently, only a user with the capability ‘bp_moderate’ can send the notice. Do you want to allow this notification feature for all users or just selected few?
In reply to: Plugin directory pagination brokenThank you for the ticket @mercime 🙂
In reply to: Plugin directory pagination brokenHi,
the problem is that currently the pagination links are broken.
for example if you put the page number manually like this
https://buddypress.org/extend/plugins/?ppage=5
It will work. After the second page, the pagination is broken .I am not sure if the moderators, developers are aware.
Hi @number_6,
Just wanted to post that it is easily doable with a small snippet of js.Please put this code in your js file.
jQuery('#whats-new').off('focus'); jQuery('#whats-new').off('blur');Please put this inside the document ready section for your theme’s js file( or please do let me know if you want me to provide the complete code).
By putting the above code, we have turned off the focus/blur events bound with the activity post box. So, There won’t be any fluctuation.
Now, we will need some css to make the activity box and the post button visible properly.
Here is the css code.
#whats-new-options{ height: 40px !important; /** I have used important to make sure that it will always be effective*/ } form#whats-new-form textarea{ height: 50px !important; }hoping that the above code works for you. Please do post back it it works for you or not?
Hi,
It is easy to do that.
Here is a function, you can put it in your bp-custom.php or your theme’s functions.phpfunction devb_show_displayed_user_email() { if( ! bp_is_user() ) return ; $user_email = bp_get_displayed_user_email(); echo "<a href='mailto:{$user_email}'>{$user_email}</a>"; }And you can call it on the user profile like this
<?php devb_show_displayed_user_email();?>and It will show the email as links.
Hope that helps.
In reply to: Activity Stream Homepage Compatibility IssuesHi,
It is a bug with BuddyPress and there is still an open ticket for the purpose.
You can see the details herehttps://buddypress.trac.wordpress.org/ticket/5087
and here
https://buddypress.trac.wordpress.org/ticket/5643At the moment, there does not seem to be a solution. The problem is that query variable ‘s’ is used for Normal WordPress search as well as BuddyPress activity search too. So, When BuddyPress activity is set as home page, the wordpress search query( which is like sitename/?s=someterm) is mistaken for BuddyPress activity search and gets handled by BuddyPress causing the trouble.
It will need some work on the way BuddyPress catches url(I am hoping that). let us hope that it makes to the core soon.
In reply to: How to Add Member Images to on Profile Pagehi @mcpeanut,
Thank you.
I actually made a mistake by including the lighbox hurriedly. I am updating to have an option to disable it.I have tested it on a few themes and it seems to have conflicts on couple of themes bacuse of my use of theme specific activity instead of supplying with the plugin.
I am looking on to improve it and I saw your suggestions yesterday there.
Please help me to improve it by providing your future suggestions here.
https://github.com/buddydev/mediapressLet us improve it together 🙂
Thank you
Brajesh