BBP_Topics_Admin::attributes_metabox_save( int $topic_id )

Pass the topic attributes for processing

Description

Parameters

$topic_id

(Required) Topic id

Return

(int) Parent id

Source

File: bp-forums/admin/topics.php

296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
public function attributes_metabox_save( $topic_id ) {
 
    if ( $this->bail() ) return $topic_id;
 
    // Bail if doing an autosave
    if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
        return $topic_id;
 
    // Bail if not a post request
    if ( ! bbp_is_post_request() )
        return $topic_id;
 
    // Nonce check
    if ( empty( $_POST['bbp_topic_metabox'] ) || !wp_verify_nonce( $_POST['bbp_topic_metabox'], 'bbp_topic_metabox_save' ) )
        return $topic_id;
 
    // Bail if current user cannot edit this topic
    if ( !current_user_can( 'edit_topic', $topic_id ) )
        return $topic_id;
 
    // Get the forum ID
    $forum_id = !empty( $_POST['parent_id'] ) ? (int) $_POST['parent_id'] : 0;
 
    // Get topic author data
    $anonymous_data = bbp_filter_anonymous_post_data();
    $author_id      = bbp_get_topic_author_id( $topic_id );
    $is_edit        = (bool) isset( $_POST['save'] );
 
    // Formally update the topic
    bbp_update_topic( $topic_id, $forum_id, $anonymous_data, $author_id, $is_edit );
 
    // Stickies
    if ( !empty( $_POST['bbp_stick_topic'] ) && in_array( $_POST['bbp_stick_topic'], array( 'stick', 'super', 'unstick' ) ) ) {
 
        // What's the haps?
        switch ( $_POST['bbp_stick_topic'] ) {
 
            // Sticky in this forum
            case 'stick'   :
                bbp_stick_topic( $topic_id );
                break;
 
            // Super sticky in all forums
            case 'super'   :
                bbp_stick_topic( $topic_id, true );
                break;
 
            // Normal
            case 'unstick' :
            default        :
                bbp_unstick_topic( $topic_id );
                break;
        }
    }
 
    // Allow other fun things to happen
    do_action( 'bbp_topic_attributes_metabox_save', $topic_id, $forum_id       );
    do_action( 'bbp_author_metabox_save',           $topic_id, $anonymous_data );
 
    return $topic_id;
}

Changelog

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