Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////// this goes in your theme's functions.php
- function my_enqueue($hook) {
- if( 'profile.php' != $hook )
- return;
- wp_register_script( 'my_profile_script',get_template_directory_uri() . '/js/my_profile_script.js',
- array('jquery') );
- wp_enqueue_script( 'my_profile_script');
- }
- add_action( 'admin_enqueue_scripts', 'my_enqueue' );
- add_action( 'show_user_profile', 'extra_user_profile_fields' );
- add_action( 'edit_user_profile', 'extra_user_profile_fields' );
- function extra_user_profile_fields( $user ) {
- ?>
- <h3><?php _e("Extra profile information", "blank"); ?></h3>
- <table class="form-table" id="mytable">
- <tr>
- <th><label for="title"><?php _e("title"); ?></label></th>
- <td>
- <input type="text" name="title" id="title" value="<?php echo esc_attr( get_the_author_meta( 'title', $user->ID ) ); ?>" class="regular-text" /><br />
- <span class="description"><?php _e("Please enter your title."); ?></span>
- </td>
- </tr>
- </table>
- <?php }
- add_action( 'personal_options_update', 'save_extra_user_profile_fields' );
- add_action( 'edit_user_profile_update', 'save_extra_user_profile_fields' );
- function save_extra_user_profile_fields( $user_id ) {
- if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }
- update_user_meta( $user_id, 'title', $_POST['title'] );
- }
- //////////// this goes in a file called my_profile_script.js /////////
- (function($) {
- $(document).ready( function() {
- var title = $('#mytable tr:eq(0)');
- $('#mytable').remove();
- $("#user_login").closest('tr').after(title);
- });
- })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement