usernamepool

 avatar
unknown
php
2 years ago
1.7 kB
38
No Index
<?php
/**
 * Plugin Name: Football Pool Register First & Last name
 * Description: Add 2 obligated fields where people need to add their name.
 * Version: 1.0
 * Author: Juanito Clyncke
 * Author URI: mailto:[email protected]
 * License: MIT
 */

// add_action( 'register_form', ['Football_Pool', 'registration_form_extra_fields'] );
// add_filter( 'footballpool_user_info_display_name', array( __CLASS__, 'change_display_name' ), null, 2 );

// Save this plugin in the wp-content/plugins folder and activate it //

class FootballPoolRegisterNames {
	public static function init_extension() {
		add_action( 'register_form', array( __CLASS__, 'registration_form_extra_names' ), null, 2 );
	}
	
	//1. Add fields. Jus the basic layout added before the dropdown.
	public static function registration_form_extra_names() {
		$first_name = ( ! empty( $_POST['first_name'] ) ) ? sanitize_text_field( $_POST['first_name'] ) : '';?>
        <p>
            <label for="first_name"><?php _e( 'Voornaam', 'mydomain' ) ?></label>
            <input type="text" name="first_name" id="first_name" class="input" value="<?php echo esc_attr(  $first_name  ); ?>" size="25" autocomplete="voornaam" required="required">
        </p>
        <?php
    	$last_name = ( ! empty( $_POST['last_name'] ) ) ? sanitize_text_field( $_POST['last_name'] ) : '';?>
        <p>
            <label for="last_name"><?php _e( 'Achternaam', 'mydomain' ) ?></label>
            <input type="text" name="last_name" id="last_name" class="input" value="<?php echo esc_attr(  $last_name  ); ?>" size="25" autocomplete="achternaam" required="required">
        </p>
        <?php
	}

	//2.
}
add_filter( 'plugins_loaded', array( 'FootballPoolRegisterNames', 'init_extension' ) );
Editor is loading...
Leave a Comment