This topic has 5 replies, 2 voices, and was last updated 8 years by sharmstr.

  • Author
  • #108223
     markob17
    Participant

    Hi,

    When displaying a members carousel, any other carousel, or even a custom members loop above the cover image header on a Buddypress member’s profile, it breaks the private message button.

    When you click the private message button to send a message to a member it tries to email the first member on the carousel or custom members loop instead of the actual member. Very odd.

    I tested this on multiple themes including Kleo default theme, my Kleo child theme, and various other themes including various default WordPress themes. This issue only occurred on Kleo. All plugins disabled during testing. Any ideas why it is only breaking on Kleo?

    If you look at the attached screenshot, you will see that it is going to email the first member (leanne) displayed on the loop/carousel instead of the the intended member (Luana).

    Really need this to work for my current project and I am stumped. Interestingly enough, if you display the carousel / loop under the cover image header, it doesn’t break the button, only when the code runs before.

    Thank you,

    Mark

    Attachments:
    You must be logged in to view attached files.
    #108253
     sharmstr
    Moderator

    How are you adding the carousel? Need to see your exact code in order to help.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #108338
     markob17
    Participant

    I’m adding the following code to the general-before-wrap.php file just after do_action(‘kleo_before_content’); section. You can also add it to other places in the theme, doesn’t matter for it breaks the private message button anytime a member loop (kleo carousel or custom) is displayed above the cover image header regardless of how it is added.

    COPY CODE
    
    <?php if ( bp_is_member() ) { ?> 
    <div class="member_avatars">
    <?php echo do_shortcode('[kleo_bp_members_carousel type="active" number="5" min_items="2" max_items="7" image_size="thumb" rounded="rounded" autoplay="yes" online="noshow" class="customclass"]'); ?>
    </div> 
    <?php } ?>
    

    For example, you can also add it via a fairly standard way of showing a custom members loop and the same thing occurs. Here’s the code I used in that testing scenario.

    COPY CODE
    
    <?php if ( bp_has_members( 'type=newest&max=6' ) ) : ?>         
                        <?php while ( bp_members() ) : bp_the_member(); ?>                      
                            <a href="<?php bp_member_permalink() ?>"><?php bp_member_avatar('type=full&width=125&height=125') ?></a>
                        <?php endwhile; ?>
    <?php endif; ?>
    

    Basically, anytime a members loop (kleo carousel or custom) is run before the cover image header ( notably the <?php do_action( ‘bp_member_header_actions’ ); ?> section of that code ), the private message button breaks.

    #108561
     sharmstr
    Moderator

    Man, that took forever to track down. Here’s whats happening. By default, BP doesnt display private message buttons in the members loop. Kleo adds that functionality in both the members directory and in your friends list located in your profile. In order to do that, it has to filter the message button arguments. Long story short, edit the following to get it to work.

    In /kleo/buddypress/buddypress-functions.php… starting around line 2074, you’ll see Private message in Members directory loop. Replace everything from that line to the bottom of the file with this.

    COPY CODE
    
    /* Private message in Members directory loop */
    function filter_message_button_link( $link = '' ) {
        $bp_user_id = (bp_get_member_user_id() ? bp_get_member_user_id() : bp_displayed_user_id() );
    	$link = wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . bp_core_get_username( $bp_user_id ) );
    	return $link;
    }
    function kleo_bp_dir_send_private_message_button() {
    	if( bp_get_member_user_id() != bp_loggedin_user_id() ) {
    		add_filter('bp_get_send_private_message_link', 'filter_message_button_link', 1, 1 );
    		add_filter('bp_get_send_message_button_args', 'kleo_bp_private_msg_args');
    		bp_send_message_button();
    	}
    }
    
    
    /**
     * Override default BP private message button to work on Friends tab
     * @since 2.2
     * @param array $btn
     * @return array
     */
    function kleo_bp_private_msg_args( $btn ) {
    
        if ( ! is_user_logged_in() ) {
            return false;
        }
    
        $btn['link_href'] = filter_message_button_link();
    
        return $btn;
    }
    

    I’m submitting this code change to the developers and I’m also copying them on this just incase this change breaks something. I dont think it will.

    Also, you dont need to edit template files to inject your carousel code. Just use the kleo_before_main hook.

    COPY CODE
    
    add_filter( 'init', 'check_member_profile');
    function check_member_profile() {
        if (bp_is_user()) {
            add_action('kleo_before_main', 'add_members_carousel', 10);
        }
    }
    
    function add_members_carousel() {
        echo '<div class="member_avatars">';
        echo do_shortcode('[kleo_bp_members_carousel type="active" number="5" min_items="2" max_items="7" image_size="thumb" rounded="rounded" autoplay="yes" online="noshow" class="customclass"]');
        echo '</div>';
    }
    

    Let me know if everything is sorted.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #108582
     markob17
    Participant

    Hi,

    Thanks so much for looking into this. I am going to try out your suggestions later on today when I get done with work and will be sure to let you know what happens. Also, I had submitted a ticket with Buddypress.org for this same issue which you may want to take a look at. There is some important information your developers may find useful. I was given a solution to get custom member loops to work by one of the Buddypress.org guys. Check out that thread here and forward it to your developers for it may be useful:
    https://buddypress.org/support/topic/possible-bug-when-displaying-a-members-loop-above-cover-image-on-member-profile/

    Regards,

    mark

    #108585
     sharmstr
    Moderator

    Its not needed, but thanks.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

Viewing 6 posts - 1 through 6 (of 6 total)

The forum ‘General questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?