bbp_get_form_topic_subscribed()

Return checked value of topic subscription

Description

Return

(string) Checked value of topic subscription

Source

File: bp-forums/topics/template.php

4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
function bbp_get_form_topic_subscribed() {
 
    // Get _POST data
    if ( bbp_is_post_request() && isset( $_POST['bbp_topic_subscription'] ) ) {
        $topic_subscribed = (bool) $_POST['bbp_topic_subscription'];
 
    // Get edit data
    } elseif ( bbp_is_topic_edit() || bbp_is_reply_edit() ) {
 
        // Get current posts author
        $post_author = bbp_get_global_post_field( 'post_author', 'raw' );
 
        // Post author is not the current user
        if ( bbp_get_current_user_id() !== $post_author ) {
            $topic_subscribed = bbp_is_user_subscribed_to_topic( $post_author );
 
        // Post author is the current user
        } else {
            $topic_subscribed = bbp_is_user_subscribed_to_topic( bbp_get_current_user_id() );
        }
 
    // Get current status
    } elseif ( bbp_is_single_topic() ) {
        $topic_subscribed = bbp_is_user_subscribed_to_topic( bbp_get_current_user_id() );
 
    // No data
    } else {
        $topic_subscribed = false;
    }
 
    // Get checked output
    $checked = checked( $topic_subscribed, true, false );
 
    return apply_filters( 'bbp_get_form_topic_subscribed', $checked, $topic_subscribed );
}

Changelog

Changelog
Version Description
bbPress (r2976) Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.