Created
December 2, 2012 12:39
-
-
Save RalfAlbert/4188469 to your computer and use it in GitHub Desktop.
Insert custom fields at user registration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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.' ) | |
) | |
); | |
} | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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