Forum Replies Created
-
In reply to: Problem with $bp->displayed_user->id
Use this instead, and you won’t need the global $bp:
bp_displayed_user_id();run during ‘init’ action
That hook may run too early.
Run it on a function hooked tobp_ready.In reply to: WP_Query and BP
I need page ID of current BP page
Which, as you’ve noted, will be 0.
And don’t expect that to change any time soon, if ever.If you want to know which BP page you are on, via a boolean, see:
In reply to: WP_Query and BPYou want to detect if they are on a non-BP page?
Try usingbp_is_blog_page() return bool True if it's a non-BP page, false otherwise.In reply to: WP_Query and BPPlease use the
codebutton when posting code.…when you want to call actions associated with specific post/page
What are you trying to do with action calls?
In reply to: Adds a navigation item to user profiles with counter$count = // code that retrieves the count $class = ( 0 === $count ) ? 'no-count' : 'count'; bp_core_new_nav_item( array( 'name' => sprintf( __( 'Animals <span class="%s">%s</span>', 'lang-domain' ), esc_attr( $class ), number_format_i18n( $count ) ), // etcA simple example:
https://gist.github.com/shanebp/5d3d2f298727a0a036e5bp_core_load_template( 'template_content' );should be
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );In reply to: Rewrite Forum Post Title?Forums are handled by the bbPress plugin.
Have you tried asking your question on the bbPress support forums?In reply to: How to display ONLY non-friended persons.Use
bp_get_friend_ids( bp_loggedin_user() )to get the friend ids.Then use the result in the
excludeparameter inbp_has_members.In reply to: How to display ONLY non-friended persons.According to codex –
When using a loop on a members profile use user_id=0 to show non-friends of the displayed user.
Where did you see that in the codex?
In reply to: Hide button created by premium pluginIs there a better way of doing it?
If we don’t have that plugin, we don’t know if there is a better way.
If that code is working for you, great.bp_is_my_profile()returns a boolean value. So all you need is:if ( bp_is_my_profile() ) {In reply to: [Resolved] database update to bp_xprofile_dataNo offense, but there are too many basic mistakes in your code to enumerate them.
Untested, but try:
function bio_profile_field(){ $user_id = bp_loggedin_user_id(); $bio = xprofile_get_field_data( 5, $user_id, 'comma' ); ?> <div id="primary" class="widget-area" role="complementary"> <h3>Bio</h3> <hr /> <form action="" method="post"> <input type="hidden" name="edit_bio" value="1"> <textarea rows="5" cols="26" name="edit_bio_text"> <?php echo $bio; ?> </textarea> <input type="submit" name="likesubmit" value="SAVE"> </form> </div> <?php } function yadigit_save_bio() { if( isset( $_POST["edit_bio"]) && $_POST["edit_bio"] == '1' ) ){ $user_id = bp_loggedin_user_id(); $value = sanitize_text_field( $_POST["edit_bio_text"] ); $field = 5; xprofile_set_field_data( $field, $user_id, $value, false ); } } add_action( 'wp', 'yadigit_save_bio' );In reply to: [Resolved] database update to bp_xprofile_dataWhy do you need the $bp global?
Use the function meant for setting profile field data, and then you don’t need the $wpdb global either.
http://stackoverflow.com/questions/12312372/how-to-update-custom-profile-field-data-in-buddypressIn reply to: Hide button created by premium pluginThat is a premium plugin – you should ask the plugin author or whoever you paid for support.
What you want should be simple to do – but unless somebody here has also paid for that plugin, nobody will be able to give you a definitive answer.
In reply to: Display online infoPlease use the
codebutton when posting code.Here is a better approach, imo:
function is_user_online( $user_id, $time=5 ) { $last_activity = bp_get_user_last_activity( $user_id ); $curr_time = time(); $diff = $curr_time - strtotime( $last_activity ); $time *= 60; // must be in seconds if( $diff < $time ) return true; else return false; }In reply to: new plugin: BuddyPress Simple EventsGot a chance to revisit this…
Both versions are now components.
BuddyPress Simple Events in the WP repo.
BuddyPress Simple Events Pro now has options for an Attending button, list of attendees, and notifications. As well as image support and Group assignment options.
Re themes: the templates have been tested with included WP themes. If there is an issue with a particular theme, the templates can be overloaded and adjusted as necessary. The layouts are bare-bones, iow. very basic layouts.
Re comment syncing: unfortunately, comment syncing is broken in BP 2.2.1. See tickets 6306 and 6294
Please , no duplicates.
Please use the
codebutton when posting code.You can’t over-ride that function, but if you aren’t using multisite, you can use the filter hook:
apply_filters( 'bp_core_validate_user_signup', $result );
Which only provides one argument: $resultSo your function should be :
add_filter('bp_core_validate_user_signup', 'validate_user_signup', 10, 1); function validate_user_signup($result) { // access to the user name: $result['user_name'] // access to the user email: $result['user_email'] //what is in errors: var_dump( $result['errors'] ) return $result; }In reply to: new registrations even after uninstallWP allows registrations without using BP.
Do you not want any registrations?
If so, did you turn off ‘Anyone can register’ in
[your site]/wp-admin/options-general.php ?In reply to: Activating the Site Tracking componentI’d var_dump the first 1000 ids and then hardcode the array into a function that loops thru the array and calls bp_blogs_add_user_to_blog – just to see if it fails.
If it does, then something else is going on.
In reply to: Activating the Site Tracking componentHow many members do you have?
Since you’re not on multisite, you could do this in function bp_blogs_record_existing_blogs:
$users = get_users( 'fields=ID' );It will return an array of IDs, instead of an array of user objects so it will be faster.
Then change the loop to this…
foreach ( $users as $id ) { bp_blogs_add_user_to_blog( $id, false, $blog_id ); }Yes, it requires hacking core files, but the hack is only temporary, correct?
In reply to: Adding Filters to the Member Directoryonly a certain level of members, or see members listed by country, that sort of thing
Those two things require different approaches to gathering member ids.
Adding the order option is easy.
But filtering the members will require specific solutions.Read this:
https://buddypress.org/support/topic/adding-new-order-by-on-members-loop/You can remove default choices by creating a template overload of this file and adjusting the select element:
buddypress\bp-templates\bp-legacy\buddypress\members\index.phpNote that it will default to ‘active’ regardless.
The issue is in the BuddyPress Live Notifications plugin.
You should report the issue and your fix to the plugin authors:
https://wordpress.org/support/plugin/bp-live-notificationIn reply to: Remove friend notifications for all activity pageYou can place this in your theme/functions.php or in bp-custom.php.
It will stop recording entries for 3 types after you include the function.
You can add othertypesas desired to the$excludearray.function steve_dont_save_activity( $activity_object ) { $exclude = array( 'new_avatar', 'updated_profile', 'friendship_created' ); if( in_array( $activity_object->type, $exclude ) ) $activity_object->type = false; } add_action('bp_activity_before_save', 'steve_dont_save_activity', 1, 1 );To delete existing entries, use the interface here
[yoursite]/wp-admin/admin.php?page=bp-activityIn reply to: Avatar preview has been stretched on BuddyPress siteIf you switch to a WP theme like 2013, does the problem persist?
If not, it’s something in your theme.What are your media settings re images? Are they square?
Here: …/wp-admin/options-media.phpHave you have set any avatar size constants in code?
See: https://codex.buddypress.org/themes/guides/customizing-buddypress-avatars/#how-to-change-buddypress-avatar-sizes