Advertisement
Guest User

Untitled

a guest
Dec 13th, 2014
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.25 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. Template Name: Signup page
  5. */
  6.  
  7. /** Sets up the WordPress Environment. */
  8. require( '../../../wp-load.php' );
  9.  
  10. add_action( 'wp_head', 'wp_no_robots' );
  11.  
  12. require( '../../../wp-blog-header.php' );
  13.  
  14. if ( is_array( get_site_option( 'illegal_names' )) && isset( $_GET[ 'new' ] ) && in_array( $_GET[ 'new' ], get_site_option( 'illegal_names' ) ) == true ) {
  15. wp_redirect( network_home_url() );
  16. die();
  17. }
  18.  
  19. /**
  20. * Prints signup_header via wp_head
  21. *
  22. * @since MU
  23. */
  24. function do_signup_header() {
  25. /**
  26. * Fires within the <head> section of the site sign-up screen.
  27. *
  28. * @since 3.0.0
  29. */
  30. do_action( 'signup_header' );
  31. }
  32. add_action( 'wp_head', 'do_signup_header' );
  33.  
  34. if ( !is_multisite() ) {
  35. wp_redirect( site_url('wp-login.php?action=register') );
  36. die();
  37. }
  38.  
  39. if ( !is_main_site() ) {
  40. wp_redirect( network_site_url( 'wp-signup.php' ) );
  41. die();
  42. }
  43.  
  44. // Fix for page title
  45. $wp_query->is_404 = false;
  46.  
  47. /**
  48. * Prints styles for front-end Multisite signup pages
  49. *
  50. * @since MU
  51. */
  52. function wpmu_signup_stylesheet() {
  53. ?>
  54. <style type="text/css">
  55. .mu_register { width: 90%; margin:0 auto; }
  56. .mu_register form { margin-top: 2em; }
  57. .mu_register .error { font-weight:normal; padding:10px; color:#333333; background:#f4edec; border:1px solid #CC0000; border-radius: 0px; -moz-border-radius: 0px; -webkit-border-radius: 0px; margin:0 0 5px 0;width: 40%;}
  58. .mu_register input[type="submit"],
  59. .mu_register #blog_title,
  60. .mu_register #user_email,
  61. .mu_register #blogname,
  62. .mu_register #user_name { margin:0; display: inline; }
  63. .mu_register input[type="submit"] { margin-bottom: 35px;}
  64. .mu_register #password_1, .mu_register #password_2 { margin:0 !important;width: 250px !important; font-size: 100% !important;}
  65. .mu_register .prefix_address,
  66. .mu_register .suffix_address {font-size: 18px;display:inline; }
  67. .mu_register label { font-size:100%; display:block; margin:15px 0 0; }
  68. .mu_register label.checkbox { display:inline; }
  69. .mu_register .mu_alert { padding:10px; color:#333333; background:#ffffe0; border:1px solid #e6db55; }
  70. .mu_register #blog_title, .mu_register #user_email, .mu_register #blogname, .mu_register #user_name {
  71. width: 250px !important;
  72. }
  73.  
  74. .widecolumn {
  75. margin: 0 auto 50px auto;
  76. float: none !important;
  77. background: #fff;
  78. }
  79.  
  80. #footer-bottom { border-bottom: 0px; }
  81.  
  82. @media only screen and ( min-width: 1301px ) {
  83.  
  84. }
  85.  
  86.  
  87. </style>
  88. <?php
  89. }
  90.  
  91. add_action( 'wp_head', 'wpmu_signup_stylesheet' );
  92. get_header();
  93.  
  94. /**
  95. * Fires before the site sign-up form.
  96. *
  97. * @since 3.0.0
  98. */
  99. do_action( 'before_signup_form' );
  100. ?>
  101.  
  102. <div id="content" class="widecolumn">
  103. <div class="mu_register">
  104. <?php
  105. /**
  106. * Generates and displays the Signup and Create Site forms
  107. *
  108. * @since MU
  109. *
  110. * @param string $blogname The new site name
  111. * @param string $blog_title The new site title
  112. * @param array $errors
  113. */
  114. function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
  115. $current_site = get_current_site();
  116. // Blog name
  117. if ( !is_subdomain_install() )
  118. echo '<label for="blogname">' . __('Site Name:') . '</label>';
  119. else
  120. echo '<label for="blogname">' . __('<strong>Site Domain</strong>:') . '</label>';
  121.  
  122. if ( $errmsg = $errors->get_error_message('blogname') ) { ?>
  123. <p class="error"><?php echo $errmsg ?></p>
  124. <?php }
  125.  
  126. if ( !is_subdomain_install() )
  127. echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span><input name="blogname" type="text" id="blogname" value="'. esc_attr($blogname) .'" maxlength="60" /><br />';
  128. else
  129. echo '<input name="blogname" type="text" id="blogname" value="'.esc_attr($blogname).'" maxlength="60" /><span class="suffix_address">.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_site->domain ) ) . '</span><br />';
  130.  
  131. if ( !is_user_logged_in() ) {
  132. if ( !is_subdomain_install() )
  133. $site = $current_site->domain . $current_site->path . __( 'sitename' );
  134. else
  135. $site = __( 'domain' ) . '.' . $site_domain . $current_site->path;
  136. echo '<p>(<strong>' . sprintf( __('Your address will be %s.'), $site ) . '</strong>) ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' ) . '</p>';
  137. }
  138.  
  139. // Blog Title
  140. ?>
  141. <label for="blog_title"><?php _e('<strong>Site Title</strong>:') ?></label>
  142. <?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?>
  143. <p class="error"><?php echo $errmsg ?></p>
  144. <?php }
  145. echo '<input name="blog_title" type="text" id="blog_title" value="'.esc_attr($blog_title).'" />';
  146. ?>
  147.  
  148. <div id="privacy">
  149. <p class="privacy-intro">
  150. <label for="blog_public_on"><?php _e('<strong>Privacy</strong>:') ?></label>
  151. <?php _e( 'Allow search engines to index this site.' ); ?>
  152. <br style="clear:both" />
  153. <label class="checkbox" for="blog_public_on">
  154. <input type="radio" id="blog_public_on" name="blog_public" value="1" <?php if ( !isset( $_POST['blog_public'] ) || $_POST['blog_public'] == '1' ) { ?>checked="checked"<?php } ?> />
  155. <strong><?php _e( 'Yes' ); ?></strong>
  156. </label>
  157. <label class="checkbox" for="blog_public_off">
  158. <input type="radio" id="blog_public_off" name="blog_public" value="0" <?php if ( isset( $_POST['blog_public'] ) && $_POST['blog_public'] == '0' ) { ?>checked="checked"<?php } ?> />
  159. <strong><?php _e( 'No' ); ?></strong>
  160. </label>
  161. </p>
  162. </div>
  163.  
  164. <?php
  165. /**
  166. * Fires after the site sign-up form.
  167. *
  168. * @since 3.0.0
  169. *
  170. * @param array $errors An array possibly containing 'blogname' or 'blog_title' errors.
  171. */
  172.  
  173. }
  174.  
  175. /**
  176. * Validate the new site signup
  177. *
  178. * @since MU
  179. *
  180. * @uses wp_get_current_user() to retrieve the current user
  181. * @uses wpmu_validate_blog_signup() to validate new site signup for the current user
  182. * @return array Contains the new site data and error messages.
  183. */
  184. function validate_blog_form() {
  185. $user = '';
  186. if ( is_user_logged_in() )
  187. $user = wp_get_current_user();
  188.  
  189. return wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $user);
  190. }
  191.  
  192. /**
  193. * Display user registration form
  194. *
  195. * @since MU
  196. *
  197. * @param string $user_name The entered username
  198. * @param string $user_email The entered email address
  199. * @param array $errors
  200. */
  201. function show_user_form($user_name = '', $user_email = '', $errors = '') {
  202. // User name
  203. echo '<label for="user_name">' . __('Username:') . '</label>';
  204. if ( $errmsg = $errors->get_error_message('user_name') ) {
  205. echo '<p class="error">'.$errmsg.'</p>';
  206. }
  207. echo '<input name="user_name" type="text" id="user_name" value="'. esc_attr($user_name) .'" maxlength="60" /><br />';
  208. _e( '<span class="smallertext">(Must be at least 4 characters, letters and numbers only.)</span><br><br>' );
  209. ?>
  210.  
  211. <label for="user_email"><?php _e( 'Email&nbsp;Address:' ) ?></label>
  212. <?php if ( $errmsg = $errors->get_error_message('user_email') ) { ?>
  213. <p class="error"><?php echo $errmsg ?></p>
  214. <?php } ?>
  215. <input name="user_email" type="text" id="user_email" value="<?php echo esc_attr($user_email) ?>" maxlength="200" /><br /><?php _e('<span class="smallertext">We will send your registration email to this address.<br>(Double-check your email address before continuing.)</span><br><br>') ?>
  216. <?php
  217. if (isset($_POST['honeypot'])) {
  218. // error condition, redisplay form
  219. }
  220. ?>
  221.  
  222. <label style="display:block;position:absolute;left:-9999px">
  223. Please leave this checkbox blank
  224. <input type=checkbox name=honeypot value=1>
  225. </label>
  226.  
  227. <?php
  228. if ( $errmsg = $errors->get_error_message('generic') ) {
  229. echo '<p class="error">' . $errmsg . '</p>';
  230. }
  231. /**
  232. * Fires at the end of the user registration form on the site sign-up form.
  233. *
  234. * @since 3.0.0
  235. *
  236. * @param array $errors An array possibly containing 'user_name' or 'user_email' errors.
  237. */
  238. do_action( 'signup_extra_fields', $errors );
  239. do_action( 'signup_blogform', $errors );
  240.  
  241. }
  242.  
  243.  
  244.  
  245. /**
  246. * Validate user signup name and email
  247. *
  248. * @since MU
  249. *
  250. * @uses wpmu_validate_user_signup() to retrieve an array of user data
  251. * @return array Contains username, email, and error messages.
  252. */
  253. function validate_user_form() {
  254. return wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']);
  255. }
  256.  
  257. /**
  258. * Allow returning users to sign up for another site
  259. *
  260. * @since MU
  261. *
  262. * @uses wp_get_current_user() to get the current user
  263. * @param string $blogname The new site name
  264. * @param string $blog_title The new blog title
  265. * @param array $errors
  266. */
  267. function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) {
  268. $current_user = wp_get_current_user();
  269.  
  270. if ( ! is_wp_error($errors) ) {
  271. $errors = new WP_Error();
  272. }
  273.  
  274. $signup_defaults = array(
  275. 'blogname' => $blogname,
  276. 'blog_title' => $blog_title,
  277. 'errors' => $errors
  278. );
  279.  
  280. /**
  281. * Filter the default site sign-up variables.
  282. *
  283. * @since 3.0.0
  284. *
  285. * @param array $signup_defaults {
  286. * An array of default site sign-up variables.
  287. *
  288. * @type string $blogname The site blogname.
  289. * @type string $blog_title The site title.
  290. * @type array $errors An array possibly containing 'blogname' or 'blog_title' errors.
  291. * }
  292. */
  293. $filtered_results = apply_filters( 'signup_another_blog_init', $signup_defaults );
  294.  
  295. $blogname = $filtered_results['blogname'];
  296. $blog_title = $filtered_results['blog_title'];
  297. $errors = $filtered_results['errors'];
  298.  
  299. echo '<h2 style="padding-top:30px;">' . sprintf( __( 'Get a new %s website' ), get_current_site()->site_name ) . '</h2>';
  300.  
  301. if ( $errors->get_error_code() ) {
  302. echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>';
  303. }
  304. ?>
  305.  
  306. <p style="padding-top:10px;"><?php _e( 'Site domain suggestions: your artist name, real name or project.' ) ?></p>
  307.  
  308. <p><?php _e( '<span class="smallertext" style="width:70%;display:block;"><strong>NOTES</strong>: You won&#8217;t be able to change your cre8tives site domain name later, so choose wisely! &#40;You <strong>will</strong> however be able to upgrade and connect using your own www domain name, so don&#8217;t stress too much. Finally, if you would like to use your <em>username</em> for your site name, we will have to set it up for you, so write us through our <a href="http://cre8tives.org/wp-admin/admin.php?page=ticket-manager">support page</a>.&#41;</span>' ) ?></p>
  309. <form id="setupform" method="post" action="wp-signup.php">
  310. <input type="hidden" name="stage" value="gimmeanotherblog" />
  311. <?php
  312. /**
  313. * Hidden sign-up form fields output when creating another site or user.
  314. *
  315. * @since MU
  316. *
  317. * @param string $context A string describing the steps of the sign-up process. The value can be
  318. * 'create-another-site', 'validate-user', or 'validate-site'.
  319. */
  320. do_action( 'signup_hidden_fields', 'create-another-site' );
  321. ?>
  322. <?php show_blog_form($blogname, $blog_title, $errors); ?>
  323. <p class="submit"><input type="submit" name="submit" class="small button secondary" value="<?php esc_attr_e( 'Create Site' ) ?>" /></p>
  324. </form>
  325. <?php
  326. }
  327.  
  328. /**
  329. * Validate a new blog signup
  330. *
  331. * @since MU
  332. *
  333. * @uses wp_get_current_user() to retrieve the current user
  334. * @uses wpmu_create_blog() to add a new site
  335. * @uses confirm_another_blog_signup() to confirm the user's new site signup
  336. * @return bool True if blog signup was validated, false if error
  337. */
  338. function validate_another_blog_signup() {
  339. global $wpdb, $blogname, $blog_title, $errors, $domain, $path;
  340. $current_user = wp_get_current_user();
  341. if ( !is_user_logged_in() )
  342. die();
  343.  
  344. $result = validate_blog_form();
  345. extract($result);
  346.  
  347. if ( $errors->get_error_code() ) {
  348. signup_another_blog($blogname, $blog_title, $errors);
  349. return false;
  350. }
  351.  
  352. $public = (int) $_POST['blog_public'];
  353.  
  354. $blog_meta_defaults = array(
  355. 'lang_id' => 1,
  356. 'public' => $public
  357. );
  358.  
  359. /**
  360. * Filter the new site meta variables.
  361. *
  362. * @since MU
  363. * @deprecated 3.0.0 Use the 'add_signup_meta' filter instead.
  364. *
  365. * @param array $blog_meta_defaults An array of default blog meta variables.
  366. */
  367. $meta = apply_filters( 'signup_create_blog_meta', $blog_meta_defaults );
  368. /**
  369. * Filter the new default site meta variables.
  370. *
  371. * @since 3.0.0
  372. *
  373. * @param array $meta {
  374. * An array of default site meta variables.
  375. *
  376. * @type int $lang_id The language ID.
  377. * @type int $blog_public Whether search engines should be discouraged from indexing the site. 1 for true, 0 for false.
  378. * }
  379. */
  380. $meta = apply_filters( 'add_signup_meta', $meta );
  381.  
  382. wpmu_create_blog( $domain, $path, $blog_title, $current_user->ID, $meta, $wpdb->siteid );
  383. confirm_another_blog_signup($domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta);
  384. return true;
  385. }
  386.  
  387. /**
  388. * Confirm a new site signup
  389. *
  390. * @since MU
  391. *
  392. * @param string $domain The domain URL
  393. * @param string $path The site root path
  394. * @param string $user_name The username
  395. * @param string $user_email The user's email address
  396. * @param array $meta Any additional meta from the 'add_signup_meta' filter in validate_blog_signup()
  397. */
  398. function confirm_another_blog_signup( $domain, $path, $blog_title, $user_name, $user_email = '', $meta = array() ) {
  399. ?>
  400. <h2 style="padding:30px 0px 30px;"><?php printf( __( 'The site %s is yours.' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2>
  401. <p>
  402. <?php printf( __( '<a href="http://%1$s">http://%2$s</a> is your new site.<br><br><a href="%3$s">Log in</a> as &#8220;%4$s&#8221; using your existing password.' ), $domain.$path, $domain.$path, "http://" . $domain.$path . "wp-login.php", $user_name ) ?>
  403. </p>
  404. <?php
  405. /**
  406. * Fires when the site or user sign-up process is complete.
  407. *
  408. * @since 3.0.0
  409. */
  410. do_action( 'signup_finished' );
  411. }
  412.  
  413. /**
  414. * Setup the new user signup process
  415. *
  416. * @since MU
  417. *
  418. * @uses apply_filters() filter $filtered_results
  419. * @uses show_user_form() to display the user registration form
  420. * @param string $user_name The username
  421. * @param string $user_email The user's email
  422. * @param array $errors
  423. */
  424. function signup_user( $user_name = '', $user_email = '', $errors = '' ) {
  425. global $active_signup;
  426.  
  427. if ( !is_wp_error($errors) )
  428. $errors = new WP_Error();
  429.  
  430. $signup_for = isset( $_POST[ 'signup_for' ] ) ? esc_html( $_POST[ 'signup_for' ] ) : 'blog';
  431.  
  432. $signup_user_defaults = array(
  433. 'user_name' => $user_name,
  434. 'user_email' => $user_email,
  435. 'errors' => $errors,
  436. );
  437.  
  438. /**
  439. * Filter the default user variables used on the user sign-up form.
  440. *
  441. * @since 3.0.0
  442. *
  443. * @param array $signup_user_defaults {
  444. * An array of default user variables.
  445. *
  446. * @type string $user_name The user username.
  447. * @type string $user_email The user email address.
  448. * @type array $errors An array of possible errors relevant to the sign-up user.
  449. * }
  450. */
  451. $filtered_results = apply_filters( 'signup_user_init', $signup_user_defaults );
  452. $user_name = $filtered_results['user_name'];
  453. $user_email = $filtered_results['user_email'];
  454. $errors = $filtered_results['errors'];
  455.  
  456. ?>
  457.  
  458. <h2 style="padding-top:30px;"><?php printf( __( 'sign up for cre8tives' ), get_current_site()->site_name ) ?></h2>
  459.  
  460. <form id="setupform" method="post" action="wp-signup.php">
  461. <input type="hidden" name="stage" value="validate-user-signup" />
  462. <?php
  463. /** This action is documented in wp-signup.php */
  464. do_action( 'signup_hidden_fields', 'validate-user' );
  465. ?>
  466. <?php show_user_form($user_name, $user_email, $errors); ?>
  467.  
  468.  
  469.  
  470.  
  471. <p><br><input type="submit" name="submit" class="button secondary" value="<?php esc_attr_e('Join') ?>" /></p>
  472. </form> <?php
  473. }
  474.  
  475. /**
  476. * Validate the new user signup
  477. *
  478. * @since MU
  479. *
  480. * @uses validate_user_form() to retrieve an array of the user data
  481. * @uses wpmu_signup_user() to signup the new user
  482. * @uses confirm_user_signup() to confirm the new user signup
  483. * @return bool True if new user signup was validated, false if error
  484. */
  485. function validate_user_signup() {
  486. $result = validate_user_form();
  487. extract($result);
  488.  
  489. if ( $errors->get_error_code() ) {
  490. signup_user($user_name, $user_email, $errors);
  491. return false;
  492. }
  493.  
  494. if ( 'blog' == $_POST['signup_for'] ) {
  495. signup_blog($user_name, $user_email);
  496. return false;
  497. }
  498.  
  499. /** This filter is documented in wp-signup.php */
  500. wpmu_signup_user( $user_name, $user_email, apply_filters( 'add_signup_meta', array() ) );
  501.  
  502. confirm_user_signup($user_name, $user_email);
  503. return true;
  504. }
  505.  
  506. /**
  507. * New user signup confirmation
  508. *
  509. * @since MU
  510. *
  511. * @param string $user_name The username
  512. * @param string $user_email The user's email address
  513. */
  514. function confirm_user_signup($user_name, $user_email) {
  515. ?>
  516. <h2 style="padding:50px 0 50px;"><?php printf( __( '%s is your new username' ), $user_name) ?></h2>
  517. <p><?php _e( 'But, before you can start using your new username, <strong>you must activate it</strong>.' ) ?></p>
  518. <p><?php printf( __( 'Check your inbox at <strong>%s</strong> and click the link we emailed you.' ), $user_email ); ?></p>
  519. <p><?php _e( 'If you do not activate your username within two days, you will have to sign up again.' ); ?></p>
  520. <?php
  521. /** This action is documented in wp-signup.php */
  522. do_action( 'signup_finished' );
  523. }
  524.  
  525. /**
  526. * Setup the new site signup
  527. *
  528. * @since MU
  529. *
  530. * @uses apply_filters() to filter $filtered_results
  531. * @uses show_blog_form() to display the blog signup form
  532. * @param string $user_name The username
  533. * @param string $user_email The user's email address
  534. * @param string $blogname The site name
  535. * @param string $blog_title The site title
  536. * @param array $errors
  537. */
  538. function signup_blog($user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '') {
  539. if ( !is_wp_error($errors) )
  540. $errors = new WP_Error();
  541.  
  542. $signup_blog_defaults = array(
  543. 'user_name' => $user_name,
  544. 'user_email' => $user_email,
  545. 'blogname' => $blogname,
  546. 'blog_title' => $blog_title,
  547. 'errors' => $errors
  548. );
  549.  
  550. /**
  551. * Filter the default site creation variables for the site sign-up form.
  552. *
  553. * @since 3.0.0
  554. *
  555. * @param array $signup_blog_defaults {
  556. * An array of default site creation variables.
  557. *
  558. * @type string $user_name The user username.
  559. * @type string $user_email The user email address.
  560. * @type string $blogname The blogname.
  561. * @type string $blog_title The title of the site.
  562. * @type array $errors An array of possible errors relevant to new site creation variables.
  563. * }
  564. */
  565. $filtered_results = apply_filters( 'signup_blog_init', $signup_blog_defaults );
  566.  
  567. $user_name = $filtered_results['user_name'];
  568. $user_email = $filtered_results['user_email'];
  569. $blogname = $filtered_results['blogname'];
  570. $blog_title = $filtered_results['blog_title'];
  571. $errors = $filtered_results['errors'];
  572.  
  573. if ( empty($blogname) )
  574. $blogname = $user_name;
  575. ?>
  576. <form id="setupform" method="post" action="wp-signup.php">
  577. <input type="hidden" name="stage" value="validate-blog-signup" />
  578. <input type="hidden" name="user_name" value="<?php echo esc_attr($user_name) ?>" />
  579. <input type="hidden" name="user_email" value="<?php echo esc_attr($user_email) ?>" />
  580. <?php
  581. /** This action is documented in wp-signup.php */
  582. do_action( 'signup_hidden_fields', 'validate-site' );
  583. ?>
  584. <?php show_blog_form($blogname, $blog_title, $errors); ?>
  585. <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Signup') ?>" /></p>
  586. </form>
  587. <?php
  588. }
  589.  
  590. /**
  591. * Validate new site signup
  592. *
  593. * @since MU
  594. *
  595. * @uses wpmu_validate_user_signup() to retrieve an array of the new user data and errors
  596. * @uses wpmu_validate_blog_signup() to retrieve an array of the new site data and errors
  597. * @uses apply_filters() to make signup $meta filterable
  598. * @uses signup_user() to signup a new user
  599. * @uses signup_blog() to signup a the new user to a new site
  600. * @return bool True if the site signup was validated, false if error
  601. */
  602. function validate_blog_signup() {
  603. // Re-validate user info.
  604. $result = wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']);
  605. extract($result);
  606.  
  607. if ( $errors->get_error_code() ) {
  608. signup_user($user_name, $user_email, $errors);
  609. return false;
  610. }
  611.  
  612. $result = wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title']);
  613. extract($result);
  614.  
  615. if ( $errors->get_error_code() ) {
  616. signup_blog($user_name, $user_email, $blogname, $blog_title, $errors);
  617. return false;
  618. }
  619.  
  620. $public = (int) $_POST['blog_public'];
  621. $meta = array ('lang_id' => 1, 'public' => $public);
  622.  
  623. /** This filter is documented in wp-signup.php */
  624. $meta = apply_filters( 'add_signup_meta', $meta );
  625.  
  626. wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta);
  627. confirm_blog_signup($domain, $path, $blog_title, $user_name, $user_email, $meta);
  628. return true;
  629. }
  630.  
  631. /**
  632. * New site signup confirmation
  633. *
  634. * @since MU
  635. *
  636. * @param string $domain The domain URL
  637. * @param string $path The site root path
  638. * @param string $blog_title The new site title
  639. * @param string $user_name The user's username
  640. * @param string $user_email The user's email address
  641. * @param array $meta Any additional meta from the 'add_signup_meta' filter in validate_blog_signup()
  642. */
  643. function confirm_blog_signup( $domain, $path, $blog_title, $user_name = '', $user_email = '', $meta = array() ) {
  644. ?>
  645. <h2 style="padding-top:50px;"><?php printf( __( 'Congratulations! Your new site, %s, is almost ready.' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2>
  646.  
  647. <p><?php _e( 'But, before you can start using your site, <strong>you must activate it</strong>.' ) ?></p>
  648. <p><?php printf( __( 'Check your inbox at <strong>%s</strong> and click the link given.' ), $user_email) ?></p>
  649. <p><?php _e( 'If you do not activate your site within two days, you will have to sign up again.' ); ?></p>
  650. <h2><?php _e( 'Still waiting for your email?' ); ?></h2>
  651. <p>
  652. <?php _e( 'If you haven&#8217;t received your email yet, there are a number of things you can do:' ) ?>
  653. <ul id="noemail-tips">
  654. <li><p><strong><?php _e( 'Wait a little longer. Sometimes delivery of email can be delayed by processes outside of our control.' ) ?></strong></p></li>
  655. <li><p><?php _e( 'Check the junk or spam folder of your email client. Sometime emails wind up there by mistake.' ) ?></p></li>
  656. <li><?php printf( __( 'Have you entered your email correctly? You have entered %s, if it&#8217;s incorrect, you will not receive your email.' ), $user_email ) ?></li>
  657. </ul>
  658. </p>
  659. <?php
  660. /** This action is documented in wp-signup.php */
  661. do_action( 'signup_finished' );
  662. }
  663.  
  664. // Main
  665. $active_signup = get_site_option( 'registration', 'none' );
  666. /**
  667. * Filter the type of site sign-up.
  668. *
  669. * @since 3.0.0
  670. *
  671. * @param string $active_signup String that returns registration type. The value can be
  672. * 'all', 'none', 'blog', or 'user'.
  673. */
  674. $active_signup = apply_filters( 'wpmu_active_signup', $active_signup );
  675.  
  676. // Make the signup type translatable.
  677. $i18n_signup['all'] = _x('all', 'Multisite active signup type');
  678. $i18n_signup['none'] = _x('none', 'Multisite active signup type');
  679. $i18n_signup['blog'] = _x('blog', 'Multisite active signup type');
  680. $i18n_signup['user'] = _x('user', 'Multisite active signup type');
  681.  
  682. if ( is_super_admin() )
  683. echo '<div class="mu_alert">' . sprintf( __( 'Greetings Site Administrator! You are currently allowing &#8220;%s&#8221; registrations. To change or disable registration go to your <a href="%s">Options page</a>.' ), $i18n_signup[$active_signup], esc_url( network_admin_url( 'settings.php' ) ) ) . '</div>';
  684.  
  685. $newblogname = isset($_GET['new']) ? strtolower(preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'])) : null;
  686.  
  687. $current_user = wp_get_current_user();
  688. if ( $active_signup == 'none' ) {
  689. _e( 'Registration has been disabled.' );
  690. } elseif ( $active_signup == 'blog' && !is_user_logged_in() ) {
  691. $login_url = site_url( 'wp-login.php?redirect_to=' . urlencode( network_site_url( 'wp-signup.php' ) ) );
  692. echo sprintf( __( '<br><br><br>You must first <a href="%s">log in</a>, then you can create a new site.<br><br><br>If you are not already a member, visit our <a href="http://cre8tives.org/join">join page</a> to learn more.<br><br><br><br><br><br><br><br><br>' ), $login_url );
  693. } else {
  694. $stage = isset( $_POST['stage'] ) ? $_POST['stage'] : 'default';
  695. switch ( $stage ) {
  696. case 'validate-user-signup' :
  697. if ( $active_signup == 'all' || $_POST[ 'signup_for' ] == 'blog' && $active_signup == 'blog' || $_POST[ 'signup_for' ] == 'user' && $active_signup == 'user' )
  698. validate_user_signup();
  699. else
  700. _e( 'User registration has been disabled.' );
  701. break;
  702. case 'validate-blog-signup':
  703. if ( $active_signup == 'all' || $active_signup == 'blog' )
  704. validate_blog_signup();
  705. else
  706. _e( 'Site registration has been disabled.' );
  707. break;
  708. case 'gimmeanotherblog':
  709. validate_another_blog_signup();
  710. break;
  711. case 'default':
  712. default :
  713. $user_email = isset( $_POST[ 'user_email' ] ) ? $_POST[ 'user_email' ] : '';
  714. /**
  715. * Fires when the site sign-up form is sent.
  716. *
  717. * @since 3.0.0
  718. */
  719. do_action( 'preprocess_signup_form' );
  720. if ( is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'blog' ) )
  721. signup_another_blog($newblogname);
  722. elseif ( is_user_logged_in() == false && ( $active_signup == 'all' || $active_signup == 'user' ) )
  723. signup_user( $newblogname, $user_email );
  724. elseif ( is_user_logged_in() == false && ( $active_signup == 'blog' ) )
  725. _e( 'Sorry, new registrations are not allowed at this time.' );
  726. else
  727. _e( 'You are logged in already. No need to register again!' );
  728.  
  729. if ( $newblogname ) {
  730. $newblog = get_blogaddress_by_name( $newblogname );
  731.  
  732. if ( $active_signup == 'blog' || $active_signup == 'all' )
  733. printf( '<p><em>' . __( 'The site you were looking for, <strong>%s</strong>, does not exist, but you can create it now!' ) . '</em></p>', $newblog );
  734. else
  735. printf( '<p><em>' . __( 'The site you were looking for, <strong>%s</strong>, does not exist.' ) . '</em></p>', $newblog );
  736. }
  737. break;
  738. }
  739. }
  740. ?>
  741. </div>
  742. </div>
  743.  
  744. <?php
  745. /**
  746. * Fires after the sign-up forms, before wp_footer.
  747. *
  748. * @since 3.0.0
  749. */
  750. do_action( 'after_signup_form' ); ?>
  751.  
  752. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement