bbp_get_form_forum_subscribed()

Return checked value of forum subscription

Description

Return

(string) Checked value of forum subscription

Source

File: bp-forums/forums/template.php

2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
function bbp_get_form_forum_subscribed() {
 
    // Get _POST data
    if ( bbp_is_post_request() && isset( $_POST['bbp_forum_subscription'] ) ) {
        $forum_subscribed = (bool) $_POST['bbp_forum_subscription'];
 
    // Get edit data
    } elseif ( bbp_is_forum_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 ) {
            $forum_subscribed = bbp_is_user_subscribed_to_forum( $post_author );
 
        // Post author is the current user
        } else {
            $forum_subscribed = bbp_is_user_subscribed_to_forum( bbp_get_current_user_id() );
        }
 
    // Get current status
    } elseif ( bbp_is_single_forum() ) {
        $forum_subscribed = bbp_is_user_subscribed_to_forum( bbp_get_current_user_id() );
 
    // No data
    } else {
        $forum_subscribed = false;
    }
 
    // Get checked output
    $checked = checked( $forum_subscribed, true, false );
 
    return apply_filters( 'bbp_get_form_forum_subscribed', $checked, $forum_subscribed );
}

Changelog

Changelog
Version Description
bbPress (r5156) 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.