New
PeoplePress is here. Community building for WordPress, reimagined. Fast, modern, and built for the communities you've always wanted to run.
See it live

BuddyDev

Search

Disable ajax in follow button

Tagged: 

  • Participant
    Level: Guru
    Posts: 922
    Tosin on #48512

    This seemed to work but its not perfect

     /**
     * Disable ajax for follow button
     */
    function disable_ajax_bp_follow() {
    	if ( bp_is_user() && is_user_logged_in() && bp_displayed_user_id() ) {
        ?>
        <script type="text/javascript">
        jQuery(document).ready(function($) {
            var itemButtons = null;
            if ($('body.bp-nouveau').length) {
                itemButtons = $('ul.member-header-actions');
            } else {
                itemButtons = $('#item-buttons');
            }
    
            if (itemButtons && itemButtons.length) {
                itemButtons.off('click', '.follow-button a.follow, .follow-button a.unfollow');
                itemButtons.on('click', '.follow-button a.follow, .follow-button a.unfollow', function(event) {
                    event.preventDefault();
                    location.reload();
                });
            }
        });
        </script>
        <?php
    }
    }
    add_action( 'wp_footer', 'disable_ajax_bp_follow', 100 ); 
  • Keymaster
    (BuddyDev Team)
    Posts: 25509
    Brajesh Singh on #48526

    Hi Tosin,
    Good to know that.

    I am glad you managed to get it working.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved