Fix tab spacing
This commit is contained in:
@@ -17,123 +17,123 @@ if ( ! class_exists( 'SportsPress_User_Registration' ) ) :
|
|||||||
* Main SportsPress User Registration Class
|
* Main SportsPress User Registration Class
|
||||||
*
|
*
|
||||||
* @class SportsPress_User_Registration
|
* @class SportsPress_User_Registration
|
||||||
* @version 2.2
|
* @version 2.2
|
||||||
*/
|
*/
|
||||||
class SportsPress_User_Registration {
|
class SportsPress_User_Registration {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
// Define constants
|
// Define constants
|
||||||
$this->define_constants();
|
$this->define_constants();
|
||||||
|
|
||||||
// Hooks
|
// Hooks
|
||||||
add_filter( 'sportspress_player_options', array( $this, 'add_player_options' ) );
|
add_filter( 'sportspress_player_options', array( $this, 'add_player_options' ) );
|
||||||
add_action( 'register_form', array( $this, 'register_form' ) );
|
add_action( 'register_form', array( $this, 'register_form' ) );
|
||||||
add_action( 'user_register', array( $this, 'user_register' ) );
|
add_action( 'user_register', array( $this, 'user_register' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define constants.
|
* Define constants.
|
||||||
*/
|
*/
|
||||||
private function define_constants() {
|
private function define_constants() {
|
||||||
if ( !defined( 'SP_USER_REGISTRATION_VERSION' ) )
|
if ( !defined( 'SP_USER_REGISTRATION_VERSION' ) )
|
||||||
define( 'SP_USER_REGISTRATION_VERSION', '2.2' );
|
define( 'SP_USER_REGISTRATION_VERSION', '2.2' );
|
||||||
|
|
||||||
if ( !defined( 'SP_USER_REGISTRATION_URL' ) )
|
if ( !defined( 'SP_USER_REGISTRATION_URL' ) )
|
||||||
define( 'SP_USER_REGISTRATION_URL', plugin_dir_url( __FILE__ ) );
|
define( 'SP_USER_REGISTRATION_URL', plugin_dir_url( __FILE__ ) );
|
||||||
|
|
||||||
if ( !defined( 'SP_USER_REGISTRATION_DIR' ) )
|
if ( !defined( 'SP_USER_REGISTRATION_DIR' ) )
|
||||||
define( 'SP_USER_REGISTRATION_DIR', plugin_dir_path( __FILE__ ) );
|
define( 'SP_USER_REGISTRATION_DIR', plugin_dir_path( __FILE__ ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add options to player settings page.
|
* Add options to player settings page.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function add_player_options( $options ) {
|
public function add_player_options( $options ) {
|
||||||
$options = array_merge( $options, array(
|
$options = array_merge( $options, array(
|
||||||
array(
|
array(
|
||||||
'title' => __( 'User Registration', 'sportspress' ),
|
'title' => __( 'User Registration', 'sportspress' ),
|
||||||
'desc' => __( 'Add name fields to signup form', 'sportspress' ),
|
'desc' => __( 'Add name fields to signup form', 'sportspress' ),
|
||||||
'id' => 'sportspress_registration_name_inputs',
|
'id' => 'sportspress_registration_name_inputs',
|
||||||
'default' => 'yes',
|
'default' => 'yes',
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
'checkboxgroup' => 'start',
|
'checkboxgroup' => 'start',
|
||||||
),
|
),
|
||||||
|
|
||||||
array(
|
array(
|
||||||
'desc' => __( 'Create player profiles for new users', 'sportspress' ),
|
'desc' => __( 'Create player profiles for new users', 'sportspress' ),
|
||||||
'id' => 'sportspress_registration_add_player',
|
'id' => 'sportspress_registration_add_player',
|
||||||
'default' => 'yes',
|
'default' => 'yes',
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
'checkboxgroup' => 'end',
|
'checkboxgroup' => 'end',
|
||||||
),
|
),
|
||||||
) );
|
) );
|
||||||
|
|
||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add name fields to user registration form.
|
* Add name fields to user registration form.
|
||||||
*/
|
*/
|
||||||
public static function register_form() {
|
public static function register_form() {
|
||||||
if ( 'yes' === get_option( 'sportspress_registration_name_inputs', 'yes' ) ) {
|
if ( 'yes' === get_option( 'sportspress_registration_name_inputs', 'yes' ) ) {
|
||||||
$first_name = ( ! empty( $_POST['first_name'] ) ) ? trim( $_POST['first_name'] ) : '';
|
$first_name = ( ! empty( $_POST['first_name'] ) ) ? trim( $_POST['first_name'] ) : '';
|
||||||
$last_name = ( ! empty( $_POST['last_name'] ) ) ? trim( $_POST['last_name'] ) : '';
|
$last_name = ( ! empty( $_POST['last_name'] ) ) ? trim( $_POST['last_name'] ) : '';
|
||||||
?>
|
?>
|
||||||
<p>
|
<p>
|
||||||
<label for="first_name"><?php _e( 'First Name', 'themeboy' ) ?><br />
|
<label for="first_name"><?php _e( 'First Name', 'themeboy' ) ?><br />
|
||||||
<input type="text" name="first_name" id="first_name" class="input" value="<?php echo esc_attr( wp_unslash( $first_name ) ); ?>" size="25" /></label>
|
<input type="text" name="first_name" id="first_name" class="input" value="<?php echo esc_attr( wp_unslash( $first_name ) ); ?>" size="25" /></label>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<label for="last_name"><?php _e( 'Last Name', 'themeboy' ) ?><br />
|
<label for="last_name"><?php _e( 'Last Name', 'themeboy' ) ?><br />
|
||||||
<input type="text" name="last_name" id="last_name" class="input" value="<?php echo esc_attr( wp_unslash( $last_name ) ); ?>" size="25" /></label>
|
<input type="text" name="last_name" id="last_name" class="input" value="<?php echo esc_attr( wp_unslash( $last_name ) ); ?>" size="25" /></label>
|
||||||
</p>
|
</p>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save fields and add player during user registration.
|
* Save fields and add player during user registration.
|
||||||
*/
|
*/
|
||||||
public static function user_register( $user_id ) {
|
public static function user_register( $user_id ) {
|
||||||
$parts = array();
|
$parts = array();
|
||||||
|
|
||||||
// Save first and last name
|
// Save first and last name
|
||||||
if ( 'yes' === get_option( 'sportspress_registration_name_inputs', 'yes' ) ) {
|
if ( 'yes' === get_option( 'sportspress_registration_name_inputs', 'yes' ) ) {
|
||||||
if ( ! empty( $_POST['first_name'] ) ) {
|
if ( ! empty( $_POST['first_name'] ) ) {
|
||||||
$meta = trim( $_POST['first_name'] );
|
$meta = trim( $_POST['first_name'] );
|
||||||
$parts[] = $meta;
|
$parts[] = $meta;
|
||||||
update_user_meta( $user_id, 'first_name', $meta );
|
update_user_meta( $user_id, 'first_name', $meta );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty( $_POST['last_name'] ) ) {
|
if ( ! empty( $_POST['last_name'] ) ) {
|
||||||
$meta = trim( $_POST['last_name'] );
|
$meta = trim( $_POST['last_name'] );
|
||||||
$parts[] = $meta;
|
$parts[] = $meta;
|
||||||
update_user_meta( $user_id, 'last_name', $meta );
|
update_user_meta( $user_id, 'last_name', $meta );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add player
|
// Add player
|
||||||
if ( 'yes' === get_option( 'sportspress_registration_add_player', 'yes' ) ) {
|
if ( 'yes' === get_option( 'sportspress_registration_add_player', 'yes' ) ) {
|
||||||
if ( ! sizeof( $parts ) && ! empty( $_POST['user_login'] ) ) {
|
if ( ! sizeof( $parts ) && ! empty( $_POST['user_login'] ) ) {
|
||||||
$parts[] = trim( $_POST['user_login'] );
|
$parts[] = trim( $_POST['user_login'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( sizeof( $parts ) ) {
|
if ( sizeof( $parts ) ) {
|
||||||
$name = implode( ' ', $parts );
|
$name = implode( ' ', $parts );
|
||||||
$post['post_type'] = 'sp_player';
|
$post['post_type'] = 'sp_player';
|
||||||
$post['post_title'] = trim( $name );
|
$post['post_title'] = trim( $name );
|
||||||
$post['post_author'] = $user_id;
|
$post['post_author'] = $user_id;
|
||||||
$post['post_status'] = 'publish';
|
$post['post_status'] = 'publish';
|
||||||
$id = wp_insert_post( $post );
|
$id = wp_insert_post( $post );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|||||||
Reference in New Issue
Block a user