i trying create plugin, in have save usermeta. code adding , saving usermeta below. usermata field being shown in userprofile section, saving doesn't anything. can please me!
function add_adslot_text() { ?> <table class="form-table"> <tr> <th><label for="afa_adslot_id">adslot id given staff</label></th> <td> <input type="text" name="afa_adslot_id" id="afa_adslot_id" value="<?php echo esc_attr( get_the_author_meta( 'afa_adslot_id', $user->id ) ); ?>" class="regular-text" /><br /> <span class="description">add adslot id given staff.</span> </td> </tr> </table> <?php } function save_adslot_text($user_id) { update_usermeta( absint( $user_id ), 'afa_adslot_id', wp_kses_post( $_post['afa_adslot_id'] ) ); } add_action('show_user_profile', 'add_adslot_text' ); add_action('edit_user_profile', 'add_adslot_text'); add_action( 'personal_options_update', 'save_adslot_text' ); add_action( 'edit_user_profile_update', 'save_adslot_text' ); register_activation_hook( __file__, 'afa_activate' );
i tried code , value saved correctly. 1 problem there while displaying saved value. $user
parameter needs passed in function add_adslot_text
.
eg:
function add_adslot_text( $user )
Comments
Post a Comment