Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Insert custom fields at user registration
<?php
/**
* Plugin Name: Custom user registration fields
* Plugin URI: http://yoda.neun12.de
* Description: Add custom fields to the user registration
* Version: 0.1
* Author: Ralf Albert
* Author URI: http://yoda.neun12.de
* Text Domain:
* Domain Path:
* Network:
* License: GPLv3
*/
add_action( 'plugins_loaded', 'wp_custom_user_registration_fields', 10, 0 );
function wp_custom_user_registration_fields(){
add_action(
'admin_print_scripts-user-new.php',
function (){
wp_enqueue_script(
'add_custom_user_registration_field',
plugins_url( 'wp_curf.js', __FILE__ ),
array( 'jquery' ),
false,
true
);
wp_enqueue_script( 'wp_curf_l10n' );
wp_localize_script(
'wp_curf_l10n',
'wp_curf_l10n',
array(
'label' => _( 'Biographical Info' ),
'description' => _( 'Share a little biographical information to fill out your profile. This may be shown publicly.' )
)
);
}
);
}
/**
* jQuery part of Costum User Registration Field
*
* @author Ralf Albert
* @version 0.1
*/
jQuery( document ).ready(
function($){
var insertElements =
'<tr class="form-field">' +
' <th scope="row"><label for="description">' + wp_curf_l10n.label + '</label></th>' +
' <td><textarea name="description" id="description" rows="5" cols="30"></textarea><br /><span class="description">' + wp_curf_l10n.description + '</span></td>' +
'</tr>';
$( '#createuser .form-table tbody' ).append( insertElements );
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.