Changeset 1683
- Timestamp:
- 06/22/2015 02:16:57 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-new-site.php
r1651 r1683 100 100 $path = isset( $url['path'] ) ? $url['path'] : ''; 101 101 102 $this->new_site_id = create_empty_blog( $url['host'], $path, 'WordCamp Event', 1 ); 102 $current_blog_id_before_new_blog = get_current_blog_id(); 103 104 $wordcamp_meta = get_post_custom( $wordcamp_id ); 105 $lead_organizer = $this->get_user_or_current_user( $wordcamp_meta['WordPress.org Username'][0] ); 106 $this->new_site_id = wpmu_create_blog( $url['host'], $path, 'WordCamp Event', $lead_organizer->ID ); 107 108 /* 109 * Work around for https://github.com/Automattic/jetpack/issues/2280 110 * @todo - remove this after that is fixed 111 */ 112 if ( get_current_blog_id() != $current_blog_id_before_new_blog ) { 113 restore_current_blog(); 114 } 115 103 116 if ( is_int( $this->new_site_id ) ) { 104 117 update_post_meta( $wordcamp_id, '_site_id', $this->new_site_id ); // this is used in other plugins to map the `wordcamp` post to it's corresponding site … … 111 124 112 125 /** 126 * Get the requested user, but fall back to the current user 127 * 128 * @param string $username 129 * 130 * @return WP_User 131 */ 132 protected function get_user_or_current_user( $username ) { 133 $lead_organizer = get_user_by( 'login', $username ); 134 135 if ( ! $lead_organizer ) { 136 $lead_organizer = wp_get_current_user(); 137 } 138 139 return $lead_organizer; 140 } 141 142 /** 113 143 * Configure a new site and populate it with default content 114 144 * … … 129 159 switch_to_blog( $this->new_site_id ); 130 160 131 $lead_organizer = get_user_by( 'login', $meta['WordPress.org Username'][0] ); 132 if ( ! $lead_organizer ) { 133 $lead_organizer = wp_get_current_user(); 134 } 135 add_user_to_blog( get_current_blog_id(), $lead_organizer->ID, 'administrator' ); 161 $lead_organizer = $this->get_user_or_current_user( $meta['WordPress.org Username'][0] ); 136 162 137 163 activate_plugins( array(
Note: See TracChangeset
for help on using the changeset viewer.