BuddyDev

Search

Disable ajax in follow button

Tagged: 

  • Participant
    Level: Guru
    Posts: 885
    Tosin on #48399

    Hi Brajesh,

    Please how can I disable the buddypress follow plugin ajax feature only in the user profile header.

    I need the follow button in the profile header and reload the page on button click

    Thanks

  • Keymaster
    (BuddyDev Team)
    Posts: 24188
    Brajesh Singh on #48417

    Hi Tosin,
    Thank you for the question.
    I am, assuming that you are using Ray’s plugin.

    Please allow me to look into it over the weekend to assist you.

    Regards
    Brajesh

  • Participant
    Level: Guru
    Posts: 885
    Tosin on #48418

    Yes im using Ray’s plugin from github

    Thanks sir

  • Keymaster
    (BuddyDev Team)
    Posts: 24188
    Brajesh Singh on #48419

    Great!
    Thank you for confirming.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 24188
    Brajesh Singh on #48474

    Hi Tosin,
    Hope you are doing well.
    I had a look at the plugin and it does not provide an entry point to disable the ajax.

    you may try adding this code to see if it works(we are turning of event handler using js)

    
    
    /**
     * Disable ajax for follow button
     */
    function tosin_disable_ajax_bp_follow() {
    	?>
    	<script>
            (function ($) {
                let $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');
                }
            })(jQuery);
    
    	</script>
    	<?php
    }
    
    add_action( 'wp_footer', 'tosin_disable_ajax_bp_follow', 100 );
    
    

    Regards
    Brajesh

  • Participant
    Level: Guru
    Posts: 885
    Tosin on #48480

    Hello Brajesh

    Thanks for the feedback please note that I’m using the legacy template as I can see body.bp-nouveau in the code

  • Keymaster
    (BuddyDev Team)
    Posts: 24188
    Brajesh Singh on #48481

    Hi Tosin,
    It is aimed at both.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 24188
    Brajesh Singh on #48483

    Hi Tosin,
    Please use the updated code as there was a minor typo which used an undefined reference.

    Regards
    Brajesh

  • Participant
    Level: Guru
    Posts: 885
    Tosin on #48503

    The code did not work, the ajax is still working instead of the whole page reloading

  • Keymaster
    (BuddyDev Team)
    Posts: 24188
    Brajesh Singh on #48504

    Thank you for letting me know.
    I haven’t tried testing the code as that would mean I need tome to setup the plugin.

    I hope you can debug(the logic is to make sure you turn off the click handler) or I will do it when i have sufficient free time.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved