'arixwp_profile_meta', //This is the nonce for this meta 'nonce_name' => 'arixwp_profile_meta_nonce', //This is the title that appears on the meta box container 'title' => 'Custom Profile Meta', //Here we define all the fields we want in the meta box 'fields' => array( array( 'before' => __( 'Hey add your custom profile meta here.', THEMENAME ), 'name' => __( 'Test Data', THEMENAME ), 'desc' => __( 'This is where you add test data.', THEMENAME ), 'id' => '_arixwp_profile_test_data', 'type' => 'text', 'default' => '' ), array( 'before' => __( 'Hey add your OTHER custom profile meta here.', THEMENAME ), 'name' => __( 'Test Data 2', THEMENAME ), 'desc' => __( 'This is where you add test data 2.', THEMENAME ), 'id' => '_arixwp_profile_test_data2', 'type' => 'text', 'default' => '' ), ) ); } function arixwp_user_profile_fields( $user ) { global $profilemeta; echo ''; foreach ( $profilemeta[ 'fields' ] as $field ) { // get current profile meta data $meta = esc_attr( get_the_author_meta( $field[ 'id' ], $user->ID ) ); if ( isset( $field[ 'before' ] ) && $field[ 'before' ] != "" ) { echo '

' . $field[ 'before' ] . '

'; } echo '

'; if ( isset( $field[ 'desc' ] ) && $field[ 'desc' ] != "" ) { echo '

' . $field[ 'desc' ] . '

'; } switch ( $field[ 'type' ] ) { case 'text': echo ''. '
'; break; case 'textarea': echo ''. '
'; break; case 'select': echo ''; break; case 'radio': foreach ( $field[ 'options' ] as $option ) { echo '' . $option[ 'name' ] . '
'; } break; case 'checkbox': echo ''; break; } echo '

'; } } function save_arixwp_user_profile_fields( $user_id ) { global $profilemeta; if ( !current_user_can( 'edit_user', $user_id ) ) { return false; } $_POST[ $profilemeta[ 'nonce_name' ] ] = isset( $_POST[ $profilemeta[ 'nonce_name' ] ] ) ? $_POST[ $profilemeta[ 'nonce_name' ] ] : ""; //Verify nonce if ( !wp_verify_nonce( $_POST[$profilemeta[ 'nonce_name' ] ], basename( __FILE__ ) ) ) { return false; } foreach ( $profilemeta[ 'fields' ] as $field ) { $old = esc_attr( get_the_author_meta( $field[ 'id' ], $user_id ) ); $new = isset( $_POST[ $field[ 'id' ] ] ) ? $_POST[ $field[ 'id' ] ] : ''; if ( $new && $new != $old ) { update_user_meta( $user_id, $field[ 'id' ], $new ); } elseif ( '' == $new && $old ) { delete_user_meta( $user_id, $field[ 'id' ], $old ); } } }