BuddyDev

Search

by bphelp

Permalink: #345

Add a image that links to profile

// This is an example how you could add an image that will link to the users profile. // I would advise wrapping it in an if statement to check if the user is logged in. // Adjust accordingly

<a href="<?php echo bp_loggedin_user_domain(); ?>"><img src="<?php bloginfo('url'); ?>/wp-content/themes/your-theme/image-name.png"></a>

#profile

by bphelp

Permalink: #307

Don't display search form for logged out visitors

// This example shows you how not to display the search form for logged out
// visitors using the bp-default theme. It uses a combination of php and CSS. Adjust it accordingly


                    form#search-form {
                            display: none;
            }



#conditionals,css,php

by bphelp

Permalink: #288

Display new topic button for moderators only

// I was asked how to accomplish this and though it may not be the most effective way it worked for me
// so I am sharing it with you
function bphelp_hide_new_topic_button() {
    if ( ! current_user_can( 'edit_others_topics' ) ) {
?>
        <style type="text/css">
            a#new-topic-button {
                display: none !important;
        }

    </style>
<?php
    }
 }
add_action ('bp_head', 'bphelp_hide_new_topic_button');
?>

#new topic button

by bphelp

Permalink: #243

A few dynamic link examples

//These links can be added to your child themes template files and styled accordingly
//I wrap these in a if statement to only display to logged in users
if ( is_user_logged_in() ) {
<a href="<?php echo bp_loggedin_user_domain(); ?>">Profile</a>//link to users profile
<a href="<?php global $current_user; echo home_url() . '/members/' . $current_user->user_login . '/friends/'; ?>">Friends</a>//link to users friends 
<a href="<?php global $current_user; echo home_url() . '/members/' . $current_user->user_login . '/messages/'; ?>">Messages</a>//link to users messages
}

#dynamic links

by Brajesh Singh

Permalink: #230

BuddyBlog change settings example to post to single category and some more

add_filter('buddyblog_post_form_settings', 'buddyblog_custom_form_settings');
function buddyblog_custom_form_settings( $settings ){

    unset( $settings['upload_count'] );
    unset( $settings['tax'][ 'post_tag'] );//no need to show posts tag

    $category = get_category_by_slug( 'blog' );

    $settings['tax']['category']['include'] = array( 0 => $category->term_id );

  return $settings;  
}

@buddyblog #buddypress #buddyblog

by Brajesh Singh

Permalink: #221

BuddyBlog Redirect to single post on new post creation or post update


//redirect to single post on save/update //in future, I will add two different options for new post/update post add_action( 'bsfep_post_saved', 'buddyblog_redirect_on_post' ); function buddyblog_redirect_on_post( $post_id ){ $post = get_post( $post_id ); $post_type = get_post_type( $post ); $post_type_details = get_post_type_object( $post_type ); $message = sprintf( __( '%s Saved as %s successfully.', 'bsfep' ), $post_type_details->labels->singular_name, get_post_status( $post_id ) ); bp_core_add_message( $message ); bp_core_redirect( get_permalink( $post_id ) ); }

@buddyblog #buddypress #buddyblog

by Brajesh Singh

Permalink: #212

Show Posts from a perticular category only on user profile, other should link to the main site when using BuddyBlog

add_filter( 'buddyblog_show_posts_on_profile', 'buddyblog_custom_permalinks_filter', 10, 2 );
function buddyblog_custom_permalinks_filter( $do_filter, $post ){

    $category = get_category_by_slug( 'blog' );

    $post_categories = get_the_category( $post->ID );

    $post_cat_ids = wp_list_pluck( $post_categories, 'term_id' );
    //if it is in blog category, show on profile
    if( in_array( $category->term_id, $post_cat_ids ) )
            return true;

    return $do_filter;

}

#buddypress #buddyblog @buddyblog

by Brajesh Singh

Permalink: #190

Remove Friendship Button on User Profile(removes add/remove/Cancel Friendship button from user profile)

//remove friendship button oon Single User profile
add_action('bp_init','bp_custom_remove_friendship_btn_on_profile');
function bp_custom_remove_friendship_btn_on_profile(){

    if ( has_action( 'bp_member_header_actions', 'bp_add_friend_button' ) ) {
            remove_action( 'bp_member_header_actions', 'bp_add_friend_button', 5 );

    }

}

#buddypress #friends #bp-hacks

by Brajesh Singh

Permalink: #182

Hide Friends of a User from Other users. Only Site Admin and the User can see his/her Friends

/**
 * Hide User Friends from Other Users
 * Only Admin or the user himself can see friends
 */
add_action('bp_friends_setup_nav','bpdev_custom_hide_friends_if_not_self');

function bpdev_custom_hide_friends_if_not_self(){
    if( bp_is_my_profile() || is_super_admin() )
        return ;

    bp_core_remove_nav_item( 'friends' );

}


You can put the above code in bp-custom.php

#buddypress #friends #bp-hack

by Brajesh Singh

Permalink: #170

Remove Activity Link(Permalink) from Activity time since on Activity Lists


/** * Remove permalink link from time since on activity list */ add_filter( 'bp_activity_permalink', 'bpdev_custom_rtemove_perlink_from_timesince',10,2 ); function bpdev_custom_rtemove_perlink_from_timesince( $time_since, $activity ){ $action = $activity-&gt;action ; $time_since = '<span class="time-since">' . bp_core_time_since( $activity-&gt;date_recorded ) . '</span>'; $content = sprintf( '%1$s %2$s', $action, $time_since ); return $content; }

You can put the above code in your theme's functions.php or bp-custom.php in plugins directory

#buddypress #activity #bp-hack