├── .gitignore ├── README.md └── custom-multisite-signups-extra-sts.php /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Custom Multisite Signups Extras - STS 2 | 3 | A plugin that utilizes hooks available in [Custom Multisite Signups plugin](https://github.com/afragen/custom-multisite-signups) to add additional registration fields to school website. -------------------------------------------------------------------------------- /custom-multisite-signups-extra-sts.php: -------------------------------------------------------------------------------- 1 | Custom Multisite Signups plugin for St. Theresa School. 7 | Requires: Custom Multisite Signups 8 | Author: Andy Fragen 9 | Author URI: http://thefragens.com 10 | Version: 0.2.0 11 | License: GNU General Public License v2 12 | License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 13 | GitHub Plugin URI: https://github.com/afragen/custom-multisite-signups-extra-sts 14 | GitHub Branch: master 15 | */ 16 | 17 | class Custom_Multisite_Signups_Extras_STS extends Custom_Multisite_Signups { 18 | 19 | public function __construct() { 20 | add_filter( 'cms_add_extra_signup_fields', array( $this, 'extra_fields' ) ); 21 | add_filter( 'cms_extra_fields_css_selectors', array( $this, 'extra_fields_selectors' ) ); 22 | add_filter( 'cms_extra_fields_css', array( $this, 'extra_fields_css' ) ); 23 | add_filter( 'cms_wpmu_validate_user_signup', array( $this, 'validate_user_signup' ) ); 24 | add_action( 'cms_extra_signup_meta', array( $this, 'cms_extra_signup_meta' ) ); 25 | add_filter( 'cms_show_extra_profile_fields', array( $this, 'how_extra_profile_fields' ) ); 26 | add_action( 'cms_save_extra_profile_fields', array( $this, 'save_extra_profile_fields' ) ); 27 | } 28 | 29 | public function extra_fields( $html ) { 30 | $street = isset( $_REQUEST['street'] ) ? (string) $_REQUEST['street'] : ''; 31 | $extra_fields[] = ''; 32 | $extra_fields[] = ''; 33 | 34 | $zip = isset( $_REQUEST['zip'] ) ? (string) $_REQUEST['zip'] : ''; 35 | $extra_fields[] = ''; 36 | $extra_fields[] = ''; 37 | 38 | 39 | $html .= implode( "\n", $extra_fields ); 40 | echo $html; 41 | } 42 | 43 | public function extra_fields_selectors( $selectors ) { 44 | $selectors .= ', .mu_register #street, .mu_register #zip'; 45 | return $selectors; 46 | } 47 | 48 | public function extra_fields_css( $css ) { 49 | $css .= ' /* CSS comment */ '; 50 | return $css; 51 | } 52 | 53 | public function validate_user_signup( $result ) { 54 | if ( empty( $_POST['street'] ) ) { 55 | $result['errors']->add( 'street', __( 'You must include a street address.' ) ); 56 | echo '
', $result['errors']->get_error_message('street'), '
'; 57 | } 58 | 59 | if ( empty( $_POST['zip'] ) ) { 60 | $result['errors']->add( 'zip', __( 'You must include a street address.' ) ); 61 | echo '', $result['errors']->get_error_message('zip'), '
'; 62 | } 63 | 64 | return $result; 65 | } 66 | 67 | public function cms_extra_signup_meta() { 68 | return array( 69 | 'street' => sanitize_text_field( $_POST['street'] ), 70 | 'zip' => sanitize_text_field( $_POST['zip'] ), 71 | ); 72 | } 73 | 74 | public function show_extra_profile_fields( $user ) { 75 | 76 | $html[] = '