• Resolved kckc

    (@kckc)


    I enabled the option, Forum Buttons>2. Activate Subscribe Button, to turn the subscribe to forum link into a button. The Button appears, with the text I want on it, but it does not work. It has no effect.

    The regular Subscribe/Unsubscribe options work ok.

    I am using Twenty-Seventeen theme.

    @jb510 I saw you had the same problem. Did you ever find a solution?

Viewing 15 replies - 1 through 15 (of 38 total)
  • I never did get the button option working. I just switched it to a link and the link works.

    For other folks reference, that thread is here.

    https://wordpress.org/support/topic/subscribe-to-forum-button-not-working/

    • This reply was modified 1 year, 4 months ago by Jon Brown.
    Plugin Author Robin W

    (@robin-w)

    @jb510 apologies that I missed your original report – not sure why I didn’t see it.

    @kckc thanks for raising this.

    I have tried it and cannot immediately replicate on my test site with twenty seventeen. It’s probably a combination of things.

    I have seen one potential issue – can you both tell me what browsers you are using?

    Plugin Contributor codejp3

    (@codejp3)

    I have tested on firefox, chromium, and midori. Also tested against traditional, block and fse themes. Subscribe button working fine on all.

    Only thing I noticed that could use a little tweaking is the margins.

    The “Mark All Topics Read” button (if enabled), doesn’t have any specific styling for it, so it inherits theme-level “input” styling, which some of themes I tested against gave it bottom margin of 24px or top margin of 12px or some kind of margin value for general input elements, which threw the whole row of buttons off. Adding this to /css/styles.php for generation would solve it to override generic input element theme styling:

    input.bsp_button1 {
        margin: 0px;
    }

    And then I noticed that if I display forum notices, the buttons overlap the notice.

    Changing the margin values in the .bsp-center class seems to be a good fit.

    From:

    .bsp-center {
        width: 100%;
        max-width: 100%;
        float: none;
        text-align: center;
        margin-top: 20px;
    }

    To:

    .bsp-center {
        width: 100%;
        max-width: 100%;
        float: none;
        text-align: center;
        margin: 10px 0px 10px 0px;
    }

    Like I said, the functionality is working just fine against 3 different themes in 3 different browsers so I was not able to replicate the issue. Just noticed a few styling tweaks.

    No worries. I never expect free support, just always thankful for it 😉

    I would have typically tested on multiple browsers, but my default is Chrome. It was a while ago and reported to me by a site owner, but to them by a user. If I recall correctly they were using Safari.

    The theme is Genesis based (Restored316 Child theme). But I’m actually working on conversion on that site to Kadence based theme (launching soon-ish). None of the forums are public or I’d send you a link, but again currently sent to show link, not button.

    The “Forum Theme Package” is just set to “bbPress Default”. Site is also running BuddyPress, but “Allow BuddyPress Groups to have their own forums” is NOT checked.

    It’s also running bbPress Private Groups though, and I wrote a custom integration between that and WooCommerce subscriptions that I keep meaning to release to .org… except I loath SVN so I’ve been putting that of for 2 years now, lol.

    Plugin Author Robin W

    (@robin-w)

    @jb510 can you set me up as a user, so I could see the site itself, and look at what is in the browser?

    I’m also author of bbp private groups, and would be really interested in seeing that integration – I could possible add it as a tab into the PG plugin. We all have tools we love and hate, and I started with SVN, so just got used to its quirks and clunkyness 🙂

    Thread Starter kckc

    (@kckc)

    I typically use Chrome, and have used Chrome any time I’m updating the bbp style pack settings. I have tested the Subscribe Button on both Chrome and Firefox. Same behaviour on both – no update happens. On both browsers, the regular subscribe/unsubscribe link works fine.

    One similarity with @jb510 is that I am also running BBPress on the same site, and also have “Allow BuddyPress Groups to have their own forums” NOT checked… I’m using the plugins on a localhost just now.

    Another thing – not sure if it’s significant, but just in case, I have the following 3 bits of custom CSS: (if there is a setting to do any of these I haven’t found it yet …)

    (i) make the display of the forum wider;

    (ii) make the ‘subscription’ toggle larger font size;

    (iii) increase size of the ‘Reply To’ and ‘Create New Topic’ text font

    .has-sidebar:not(.error404) #primary {
    width: 100% !important;
    }
    a.subscription-toggle {
    font-size: 16px !important;
    }
    fieldset.bbp-form legend {
    font-size: 16px !important ;
    }

    Plugin Contributor codejp3

    (@codejp3)

    I’m going to install BuddyPress and the private groups plugin on my test site. Seems like the most likely culprit give both of your feedback so far. I’ll chime back in here if I can replicate the issue.

    Plugin Contributor codejp3

    (@codejp3)

    @kckc & @jb510 – You’re not crazy! 🙂

    Confirmed. The conflict is not with the private groups plugin, but BuddyPress directly.

    I can replicate the issues with just:
    bbPress
    BuddyPress
    Style Pack

    Happens in all 3 of my browsers, and regardless of which theme is active.

    Now to figure out WHY. No client-side errors showing in dev tools and no server-side errors showing in the debug log. Probably a conflict with something in BuddyPress being named the same thing as something in bbPress/Style Pack.

    Will keep digging until I find the culprit.

    Awesome! I’m headed for wcasia today. I’ll reach out via slack about the private group connector. I built it specifically for my wife’s site so it’s not the prettiest thing, but i anm intending to polish it a little and publish it. Would love your input and/or help on it.

    Plugin Author Robin W

    (@robin-w)

    so the html code that executes this is the same for subscribe button and subscribe subscribe link with just bbpress and style pack

    but add buddypress and the subscribe link changes from

    <a href="/forums/forum/group-a/?action=bbp_unsubscribe&amp;object_id=31865&amp;object_type=post&amp;_wpnonce=00b1e8f314" class="subscription-toggle" data-bbp-object-id="31865" data-bbp-object-type="0" data-bbp-nonce="00b1e8f314" rel="nofollow">Unsubscribe</a>

    to:

    <a href="/forums/forum/group-a/?bbp-ajax=true&amp;action=bbp_unsubscribe&amp;object_id=31865&amp;object_type=post&amp;_wpnonce=00b1e8f314" class="subscription-toggle" data-bbp-object-id="31865" data-bbp-object-type="0" data-bbp-nonce="00b1e8f314" rel="nofollow">Unsubscribe</a>
    

    ie with buddypress this is added to the call

    ?bbp-ajax=true
    • This reply was modified 1 year, 4 months ago by Robin W.
    Plugin Author Robin W

    (@robin-w)

    but just adding that doesn’t seem to fix

    Plugin Contributor codejp3

    (@codejp3)

    Yeah I tried that too. Then I thought, well maybe it also wants it to be wrapped in the span class=subscription-toggle that bbPress uses, but that didn’t work either.

    I think it may take a full rewrite of the current bsp_subscribe_button() function in Style Pack /includes/functions.php so that it uses bbp_get_user_subscribe_link() instead of bbp_get_forum_subscription_link().

    Full function details can be found in /bbpress/includes/users/templates.php around line 1300-ish:

    bbp_get_user_subscribe_link( $args = array(), $user_id = 0, $wrap = true )

    args array:

    'subscribe'   => esc_html__( 'Subscribe',   'bbpress' ),
    'unsubscribe' => esc_html__( 'Unsubscribe', 'bbpress' ),
    'user_id'     => 0,
    'object_id'   => 0,
    'object_type' => 'post',
    'before'      => '',
    'after'       => '',
    'redirect_to' => '',

    minimum required args:

    user_id
    object_id
    object_type
    Plugin Contributor codejp3

    (@codejp3)

    @robin-w – I found the fix, but it’s quite complicated. Quick overview –

    1.) JS needs to be added for the ajax function including custom button class. It has to be generated based on custom user class or default bsp_button1 class. Also requires the new file to be generated within the main plugin file and within admin settings. Only enqueued in /includes/generate_css.php if bsp_style_settings_sub_management[subscriptions_management_activate] active. Also has to be multisite friendly.

    2.) bsp_subscribe_button() function re-written to use bbp_get_user_subscribe_link() which includes ajax action call.

    This brings up another change that could/should be implemented in /includes/settings.php. Within the “$_REQUEST[‘updated’]” success message, include a check for which plugin tab is active, and if that plugin tab deals with file generations then regenerate the files for only THAT TAB. It looks like most tabs generate files individually instead of within the main settings file, and they do so every page load instead of only when saved settings have changed.

    I’m making these changes now and will send you a new pre-pub version to check out soon. Just wanted to give you the heads up so that we’re not both tackling the same problem.

    Plugin Contributor codejp3

    (@codejp3)

    @robin-wDONE

    @jb510 & @kckc – If you’re comfortable raw-editing the plugin files, you can make these changes too and “beta test them” before they’re rolled-out in the next plugin release.

    The approach I listed above seemed like overkill for such a simple task, so I walked away for a while and thought about it.

    It can actually be accomplished using the default bbPress ajax without having to deal with any custom JS file generations by just including the expected CSS selectors within the button rendering.

    It’s simplified enough that I don’t have to add a new branch on GitHub. I’m just going to post the changes here, you can apply them locally and test them out and roll them out in the next release when you’re happy that it’s working right.

    Change #1:

    In /includes/functions.php, replace the entire bsp_subscribe_button() function (lines 335-356) with:

    // Actually display/render the subscription button
    function bsp_subscribe_button() {
        
    	global $bsp_style_settings_buttons;
            
            // setup the button with custom description if set
            if ( ! empty( $bsp_style_settings_buttons['subscribe_button_description'] ) ) $args['subscribe'] = $bsp_style_settings_buttons['subscribe_button_description'];
            if ( ! empty( $bsp_style_settings_buttons['unsubscribe_button_description'] ) ) $args['unsubscribe'] = $bsp_style_settings_buttons['unsubscribe_button_description'];
    
            // setup remaining required arguments
            $args['user_id'] = bbp_get_user_id( get_current_user_id(), true, true );
            $args['object_id'] = bbp_get_forum_id();
            $args['object_type'] = 'post';
            
            // render the button with arguments
            bbp_user_subscribe_link( $args );
    
    }
    
    
    // Apply filter to the subscription button to make sure the class and descriptions are applied
    function bsp_subscribe_button_filter( $html, $args ) {
        
        global $bsp_style_settings_buttons;
        
        // change "Subscribe" text within the html only if needed
        if ( ! empty( $bsp_style_settings_buttons['subscribe_button_description'] ) ) {
                if ( $args['subscribe'] !== $bsp_style_settings_buttons['subscribe_button_description'] ) {
                        $html = preg_replace('/'.$args['subscribe'].'/', esc_attr( $bsp_style_settings_buttons['subscribe_button_description'] ), $html);
                }
        }
        
        // change "Unsubscribe" text within the html only if needed
        if ( ! empty( $bsp_style_settings_buttons['unsubscribe_button_description'] ) ) {
                if ( $args['unsubscribe'] !== $bsp_style_settings_buttons['unsubscribe_button_description'] ) {
                        $html = preg_replace('/'.$args['unsubscribe'].'/', esc_attr( $bsp_style_settings_buttons['unsubscribe_button_description'] ), $html);
                }
        }
        
        // setup the class for the link
        if ( $bsp_style_settings_buttons['button_type'] == 2 ) $class = $bsp_style_settings_buttons['Buttonclass'];
        else $class = 'bsp_button1';
    
        // apply the class to the link html
        $pattern = '/class="subscription-toggle"/' ;
        $replace = 'class="subscription-toggle '.$class.'"';
        $html = preg_replace( $pattern, $replace, $html );
        
        // return the customized link html
        return $html;
    
    }
    add_filter( 'bbp_get_user_subscribe_link', 'bsp_subscribe_button_filter', 10, 2 );

    Change #2:

    At the bottom of /css/styles.php just before the “custom css” generation, add this:

    /*----------------------  button fixes to work with default bbPress buttons and override theme values that make buttons look wrong --------------------------*/
    
    /* override bbpress floating subscription link to the right */
    #bbpress-forums div.bsp-center #subscription-toggle {
        float: none;
    }
    
    /* override any theme margins for generic input css so the mark as read button alignment matches */
    input.bsp_button1 {
        margin: 0px;
    }

    Change #3 (optional) (fixes the buttons clashing with the notices block):

    Also in /css/styles.php on line 3609 replace:

    		.bsp-center
    		{
    			width: 100%;
    			max-width: 100%;
    			float: none;
    			text-align: center;
    			margin-top: 20px;
    		}

    with:

    		.bsp-center
    		{
    			width: 100%;
    			max-width: 100%;
    			float: none;
    			text-align: center;
    			margin: 10px 0px 10px 0px;
    		}

    That’s It!

    If you WANT to over-complicate the solution like I was initially doing by trying to keep the current bsp button generation method intact, then I have a few hundred lines of code spanning across 5 or 6 different files that I can send your way. Just seemed like overkill and unnecessary. This approach uses the default bbPress html code and ajax, but just applies the custom wording/class to them.

    I’ve tested with and without BuddyPress active, with multiple themes, and with multiple browsers. Good-to-go as far as I can tell. Plus the button now actually uses ajax without reloading the page, which is a nice touch! 🙂

    • This reply was modified 1 year, 4 months ago by codejp3. Reason: added optional change #3
    Plugin Author Robin W

    (@robin-w)

    @jb510 & @kckc changes done and released in 5.3.4

    @codejp3 cheers for this, just looked at these and tested whilst waiting for my beloved to change for dinner 🙂

    all released in 5.3.4

Viewing 15 replies - 1 through 15 (of 38 total)
  • The topic ‘Subscribe to Forum Button not working’ is closed to new replies.