Skip to:
Content
Pages
Categories
Search
Top
Bottom

Subscribe link shortcode


  • dwl003
    Participant

    @dwl003

    Hi,

    Would it be possible to create a shortcode which returns the subscribe/unsubscribe link for a given forum ? The end result would be something along the lines of:

    [bbp-subscribe-link forum_id=’557′]

    The returned link would display “Subscribe” or “Unsubscribe” depending on the current state of subscription.

    This would allow a little more flexibility in placement of the link in the top part of a page with the forum embedded.

    Any help would be appreciated.

    Thanks

    Dennis

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

  • simjohna
    Participant

    @simjohna

    If you have a WordPress.com account, then you can use that or you can create a free account. Once you have connected Jetpack to WordPress.com, you need to visit Appearance » Widgets. Drag and drop Blog Subscriptions (Jetpack) widget to a sidebar and then click on Save button store your widget settings.


    dwl003
    Participant

    @dwl003

    Hi simjonna,

    Thanks for your reply. I think you have misunderstood my question. What I am looking for is the code to create a shortcode which returns the subscribe/unsubscribe link. It would be added to my theme’s functions.php and look something like this:

    function bp_subscribe_shortcode() {	
      ... logic to create a URL to subscribe, unsubscribe...
    } 
    add_shortcode( 'bbp-subscribe-link', 'bp_subscribe_shortcode' );

    It would accept one input: the ID of the forum, e.g.:

    [bbp-subscribe-link forum_id=’557′]

    It can then be placed in a page or a post etc.

    Any help appreciated.

    Thanks

    Dennis


    Robin W
    Moderator

    @robin-w

    for

    [bbp-subscribe-link forum_id=’557′]

    this code (untested) should be close

    function bp_subscribe_shortcode($attr) {	
    //must have a forum_id or we just return !
      if (empty( $attr['forum_id'])) return	;
      else $args['forum_id'] = $attr['forum_id'];
      echo bbp_forum_subscription_link($args) ;
    } 
    
    add_shortcode( 'bbp-subscribe-link', 'bp_subscribe_shortcode' );

    Robin W
    Moderator

    @robin-w

    coma back if that doesn’t work and you can’t fix it


    dwl003
    Participant

    @dwl003

    Hi Robin,

    Thanks for the suggested code. I tried it but it keeps returning nothing when specifying an existing forum ID. I checked that $attr contains the specified forum_id, but am unsure on how to troubleshoot bbp_forum_subscription_link().

    Any help would be appreciated.

    Thanks

    Dennis


    Robin W
    Moderator

    @robin-w

    no problem, I’ll load to to my test site when I get a moment

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Skip to toolbar