Customizing BBPress custom reply button

Hello,
I have a few things that I need to do with my custom reply button.
1. Remove the reply button at the top.
On this page: http://yourtechadvisors.com/forums/topic/progress-report-for-january-2016/
There is a reply button at the top of the page. I would like to make this one go away without hiding the one at the bottom, is this possible? To just display 1? First screenshot.
2. There is a button that says Reply and a button that says Create Topic, when either of these buttons are clicked, the button disappears. Is there any way to show a button that says Cancel and this button would then hide the form again?
Support access is open.
Thanks.

  • Sajid
    • DEV MAN’s Sidekick

    Hi Alex,

    Hope you are doing good today :slight_smile:

    I came up with following jQuery code solution for your issues. I am not sure whether the second issue will be solved because jQuery does not work on hidden elements but it worth trying.

    <script type="text/javascript">
    	jQuery(document).ready(function($){
    		$('.forums.bbp-replies').prev('.custom-reply-button').remove();
    
    		$('.bbp-reply-form').css('display','block');
    
    		$('.bbp-reply-form').append('<a class="cancel-reply" href="#">Cancel</>');
    
    		$('.bbp-reply-form').css('display','none');
    
    		$('.cancel-reply').click(function(){
    
    			$('.bbp-reply-form').css('display','none');
    			$('.custom-reply-button').css('display','block');
    
    		});
    	});
    </script>

    Add it in footer.php file of theme and let me know how it goes :slight_smile:

    Cheers, Sajid

  • Sajid
    • DEV MAN’s Sidekick

    Hi Alex,

    Hope you are doing good today :slight_smile:

    For messing style issue with reply button when you click on cancel button, find this code in the code I provided you above:
    $('.custom-reply-button').css('display','block');
    And replace it with this one:
    $('.custom-reply-button').css('display','inline-block');

    The video is too short and did not helped at all to see the issue.

    The code I provide above was not meant effect on create button. Do you want to do the same with create button as well ?

    Also, for future reference, please always start separate thread for each question to get faster response and according to our forum posting rules.

    Cheers, Sajid

  • Alex Stine
    • System Administrator

    Hello,
    I would like to do the same to Create Topic button, but if you really want me to open a new ticket I will. I figured it would just be easier to answer related questions here. It also helps me to keep up with these requests when they are not going every which direction. Might want to be something to talk about with staff.

    EDIT: The code worked to fix the Reply button, that is what the video was trying to show you. However, it still returns you to the top of the page, is there a way to stop that?

    Thanks @Sajid

  • Michael Bissett
    • Recruit

    Hey @Alex,

    Just to back up a moment, the code in question (regarding the topic reply form) mentioned on the live chat would be this:

    <script type="text/javascript">
    	jQuery(document).ready(function($){
    		$('.forums.bbp-replies').prev('.custom-reply-button').remove();
    
    		$('.bbp-reply-form').css('display','block');
    
    		$('.bbp-reply-form').append('<a class="cancel-reply" href="#">Cancel</>');
    
    		$('.bbp-reply-form').css('display','none');
    
    		$('.cancel-reply').click(function(e){
    			e.preventDefault();
    			$('.bbp-reply-form').css('display','none');
    			$('.custom-reply-button').css('display','inline-block');
    
    		});
    	});
    </script>

    A call to preventDefault needed to be added in, otherwise the browser's taking the user up to the top of the page (as it does by default).

    As for this:

    I still need to remove the 1 other Create Topic button

    Over on the forums page you mentioned:

    http://yourtechadvisors.com/forums/forum/staff/

    That 1st Create Topic button can be hidden with this:

    .bbp-template-notice.info + .bbp-pagination + .custom-newtopic-button {
        display: none !important;
    }

    (granted, !important is not to be used for every single case, but it's needed for this one)

    I've inserted that CSS into Simple Custom CSS, can you confirm that the code is doing what it should on your end, please? :slight_smile:

    As for the creation of the cancellation button for the Forums page, this can be done with a duplication (and slight alteration) of my colleague Sajid's code, I've inserted it alongside his code in your footer.php:

    $('.forums.bbp-replies').prev('.custom-newtopic-button').remove();
    
    		$('.bbp-topic-form').css('display','block');
    
    		$('.bbp-topic-form').append('<a class="cancel-reply" href="#">Cancel</>');
    
    		$('.bbp-topic-form').css('display','none');
    
    		$('.cancel-reply').click(function(e){
    			e.preventDefault();
    			$('.bbp-topic-form').css('display','none');
    			$('.custom-newtopic-button').css('display','inline-block');
    
    		});

    Can you confirm that it's working over on your end, please?

    Kind Regards,
    Michael

    P.S. This is the part of the program where I'll mention that we've gone into quite a bit of custom code here, and I would like to mention our policy on that, once again:

    https://premium.wpmudev.org/manuals/using-wpmu-dev/support-vs-custom-development/

    I'm only mentioning this because we've been offering a good deal of code lately, and that policy is there for a reason, to try to keep the support humming along as smoothly as possible for all members (like yourself). :slight_smile:

  • Michael Bissett
    • Recruit

    Hey @Alex,

    Glad to hear that we've got things sorted here. :slight_smile:

    The general point of my P.S. was to serve as a gentle reminder of the custom development policy that we have, as there can be cases where something does really fit more into that category.

    I know what you mean about determining the work involved behind the execution of an idea, sometimes the idea itself can be quite simple, and the path to getting there is... well, decidedly un-simple! :smiley:

    Hope you have a nice night yourself, take care! :slight_smile:

    Kind Regards,
    Michael

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.