Skip to:
Content
Pages
Categories
Search
Top
Bottom

Buddypress Starred button redirects users to their post page button

  • @dono12

    Participant

    The New Feature in Buddypress Starred button redirects users to their post page button. I’ve added a button to users buddypress activity page which is titled Post that takes users to a page with a list of their Posts made to WordPress. With the new update when you click on the Starred button the user is redirected to the the list of posts. I created the Post button using this custom function I found Online.

    /* ——————————Start BP Post in profile code for function——————– */
    function importSomething(){
    return include_once ‘bp-custom.php’;
    }
    add_action( ‘bp_setup_nav’, ‘buddyboss_child_bp_nav_adder’ );
    add_action( ‘bp_template_content’, ‘profile_buddyboss_child_loop’ );
    bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘members/single/plugins’ ) );

    function buddyboss_child_bp_nav_adder() {
    global $bp;
    $post_count = count_user_posts_by_type( $bp->displayed_user->id );
    bp_core_new_nav_item(
    array(
    ‘name’ => sprintf( __( ‘Posts <span>%d</span>’, ‘my-poems’ ), $post_count ),
    ‘slug’ => ‘Articles’,
    ‘position’ => 250,
    ‘show_for_displayed_user’ => true,
    ‘screen_function’ => ‘buddyboss_child_list’,
    ‘item_css_id’ => ‘articles’,
    ‘default_subnav_slug’ => ‘public’
    ));
    }
    function buddyboss_child_list() {
    add_action( ‘bp_template_content’, ‘profile_buddyboss_child_loop’ );
    bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘members/single/plugins’ ) );
    }
    /*——- This is end of the code for above function ———*/
    function profile_buddyboss_child_loop() {
    $myposts = get_posts( array(
    ‘posts_per_page’ => -1,
    ‘author’ => bp_displayed_user_id(),
    ‘post_type’ => ‘post’
    ));
    if( ! empty($myposts) ) {
    foreach($myposts as $post) {
    setup_postdata( $post );
    if (has_post_thumbnail( $post->ID ) ):
    $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), ‘sidebar-smallthumbnew’ );
    else :
    $image[0] = “…/wp-content/themes/Starkers-Child-2/images/vidimage.jpg”;
    endif;
    echo ‘<li class=”sidebar mostpop post-‘ . $post->ID . ‘”><div id=”postimage”>ID) . ‘”></div><div id=”postinfo”>ID) . ‘”>’ . get_the_title($post->ID) . ‘</div>‘;
    }
    echo ‘‘;
    wp_reset_postdata();
    } else { ?>
    <div class=”info” id=”message”>
    <p><?php bp_displayed_user_fullname(); ?> has No posts.</p>
    </div>
    <?php }
    }
    /* This is end of the code for above function */
    remove_filter(‘bp_setup_nav’,”);
    function count_user_posts_by_type( $userid, $post_type = ‘post’ ) {
    global $wpdb;
    $where = get_posts_by_author_sql( $post_type, true, $userid, true);
    $count = $wpdb->get_var( “SELECT COUNT(*) FROM $wpdb->posts $where” );
    return apply_filters( ‘get_usernumposts’, $count, $userid );
    }
    /* ——————————This is end of the code for post in profile above function——————– */

    I dont want to get rid of the latest starred button feature, so How can I go about correcting this redirect error.

    Also the new mobile take picture update doesn’t work on the mobile version of my site. I’m using WP-Smart mobile plugin to generate a mobile theme. I also have a copy of Buddypress in both my Child Theme and my active WP smart mobile theme.

    How can I go about fixing these issues if possible.

    Also, great exceptional work on these new updates.

    Thank you

Viewing 8 replies - 1 through 8 (of 8 total)
  • @r-a-y

    Keymaster

    @dono12 – I have split your post into a separate thread.

    About the “Starred” feature, do you mean the star private messages feature that you can access under “Messages > Starred”? If not, then this isn’t related to any change in BuddyPress 2.3.0.

    Your issue doesn’t sound like it is related to the Messages component, so can you clarify?

    @dono12

    Participant

    Yes it is related to “Messages > Starred”. There is nothing wrong with the new feature. It’s this function that I found online that’s causing a conflict.

    /* ——————————Start BP Post in profile code for function——————– */
    function importSomething(){
    return include_once ‘bp-custom.php’;
    }
    add_action( ‘bp_setup_nav’, ‘buddyboss_child_bp_nav_adder’ );
    add_action( ‘bp_template_content’, ‘profile_buddyboss_child_loop’ );
    bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘members/single/plugins’ ) );

    function buddyboss_child_bp_nav_adder() {
    global $bp;
    $post_count = count_user_posts_by_type( $bp->displayed_user->id );
    bp_core_new_nav_item(
    array(
    ‘name’ => sprintf( __( ‘Posts <span>%d</span>’, ‘my-poems’ ), $post_count ),
    ‘slug’ => ‘Articles’,
    ‘position’ => 250,
    ‘show_for_displayed_user’ => true,
    ‘screen_function’ => ‘buddyboss_child_list’,
    ‘item_css_id’ => ‘articles’,
    ‘default_subnav_slug’ => ‘public’
    ));
    }
    function buddyboss_child_list() {
    add_action( ‘bp_template_content’, ‘profile_buddyboss_child_loop’ );
    bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘members/single/plugins’ ) );
    }
    /*——- This is end of the code for above function ———*/
    function profile_buddyboss_child_loop() {
    $myposts = get_posts( array(
    ‘posts_per_page’ => -1,
    ‘author’ => bp_displayed_user_id(),
    ‘post_type’ => ‘post’
    ));
    if( ! empty($myposts) ) {
    foreach($myposts as $post) {
    setup_postdata( $post );
    if (has_post_thumbnail( $post->ID ) ):
    $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), ‘sidebar-smallthumbnew’ );
    else :
    $image[0] = “…/wp-content/themes/Starkers-Child-2/images/vidimage.jpg”;
    endif;
    echo ‘<li class=”sidebar mostpop post-‘ . $post->ID . ‘”><div id=”postimage”>ID) . ‘”></div><div id=”postinfo”>ID) . ‘”>’ . get_the_title($post->ID) . ‘</div>‘;
    }
    echo ‘‘;
    wp_reset_postdata();
    } else { ?>
    <div class=”info” id=”message”>
    <p><?php bp_displayed_user_fullname(); ?> has No posts.</p>
    </div>
    <?php }
    }
    /* This is end of the code for above function */
    remove_filter(‘bp_setup_nav’,”);
    function count_user_posts_by_type( $userid, $post_type = ‘post’ ) {
    global $wpdb;
    $where = get_posts_by_author_sql( $post_type, true, $userid, true);
    $count = $wpdb->get_var( “SELECT COUNT(*) FROM $wpdb->posts $where” );
    return apply_filters( ‘get_usernumposts’, $count, $userid );
    }
    /* ——————————This is end of the code for post in profile above function——————– */

    It adds a new button on the user activity page and when the Message-Starred button is clicked it takes the user the lists of post page that the above function creates. How can I stop that fro happening. I really want to keep the starred message function and I don’t want to lose the lists of WordPress post in the user Activity page.

    @r-a-y

    Keymaster

    Remove the first call to:

    bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );

    @dono12

    Participant

    I need some help. I’ve decided to remove the the messages->starred from BBP Activity and the Admin bar links.
    I’ve tried a lot of functions and none of them seem to be working.

    four examples:

    1. $bp->bp_nav[‘starred’] = false;

    2. function remove_nav_items() {
    bp_core_remove_nav_item( ‘starred’ );
    }
    add_action( ‘bp_setup_nav’, ‘remove_nav_items’);
    // ——- End Removes Forum link Activity feed ————- //

    // ——- Removes member link forum AdminBar ————- //

    3. $wp_admin_bar->remove_menu(‘starred’);

    4. function the_bp_admin_bar_remove() {
    global $wp_admin_bar;
    $wp_admin_bar->remove_menu( ‘my-account-starred’ );
    }
    add_action( ‘bp_setup_admin_bar’, ‘the_bp_admin_bar_remove’, 301 );

    I’ve done so successfully using CSS but I would like to use the functions instead. Can you please help?

    li#starred-personal-li{
    display:none;
    }
    li#wp-admin-bar-my-account-messages-starred{
    display:none;
    }

    @r-a-y

    Keymaster

    Add the following to wp-content/plugins/bp-custom.php or your theme’s functions.php:

    add_filter( 'bp_is_messages_star_active', '__return_false' );

    @dono12

    Participant

    That didn’t work. I lost the page with user Posts and The messages->button stills take you the posts. I think it’s best for me to remove the Starred button for the time being. Ho can I go about doing so using a function?

    @r-a-y

    Keymaster

    It’s working for me.

    Where are you putting the add_filter() line?

    Your problem sounds like it’s caused by a variety of copy-and-pasted code snippets.

    @dono12

    Participant

    I just saw the add_filter( ‘bp_is_messages_star_active’, ‘__return_false’ );
    Placed it in mu function.php

    It worked like a charm. Thanks a lot, I really appreciate your help with this.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Buddypress Starred button redirects users to their post page button’ is closed to new replies.
Skip to toolbar