Making WordPress.org

Changeset 152


Ignore:
Timestamp:
12/14/2013 01:56:11 AM (11 years ago)
Author:
iandunn
Message:

Post Types: Set speaker as author of session post.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/wc-post-types.php

    r104 r152  
    11651165        foreach ( $speaker_ids as $speaker_id )
    11661166            add_post_meta( $post_id, '_wcpt_speaker_id', $speaker_id );
     1167       
     1168        // Set the speaker as the author of the session post, so the single
     1169        // view doesn't confuse users who see "posted by [organizer name]"
     1170        foreach ( $speaker_ids as $speaker_post ) {
     1171            $wporg_user_id = get_post_meta( $speaker_post, '_wcpt_user_id', true );
     1172            $user = get_user_by( 'id', $wporg_user_id );
     1173           
     1174            if ( $user ) {
     1175                remove_action( 'save_post', array( $this, 'save_post_session' ), 10, 2 );   // avoid infinite recursion
     1176                wp_update_post( array(
     1177                    'ID'          => $post_id,
     1178                    'post_author' => $user->ID
     1179                ) );
     1180                add_action( 'save_post', array( $this, 'save_post_session' ), 10, 2 );
     1181               
     1182                break;
     1183            }
     1184        }
    11671185    }
    11681186
Note: See TracChangeset for help on using the changeset viewer.