Home / Admin / Add the fields to the user edit screen
Duplicate Snippet

Embed Snippet on Your Site

Add the fields to the user edit screen

Code Preview
php
<?php
// Add the fields to user edit screen.
add_action( 'show_user_profile', 'add_extra_user_fields' );
add_action( 'edit_user_profile', 'add_extra_user_fields' );
function add_extra_user_fields( $user ){
	// Document file URL.
	$document_file_url = ( $user->_wcv_custom_settings_doc_example ) ? wp_get_attachment_url( $user->_wcv_custom_settings_doc_example ) : '';
	// Image file URL.
	$image_file_url = ( $user->_wcv_custom_settings_doc_example ) ? wp_get_attachment_url( $user->_wcv_custom_settings_image_example ) : '';
	// Aduio file URL.
	$audio_file_url = ( $user->_wcv_custom_settings_doc_example ) ? wp_get_attachment_url( $user->_wcv_custom_settings_audio_example ) : '';
	// Video file URL.
	$video_file_url = ( $user->_wcv_custom_settings_doc_example ) ? wp_get_attachment_url( $user->_wcv_custom_settings_video_example ) : '';
?>
    <h3><?php _e( "Signup Docs", "textdomain"); ?></h3>
    <table class="form-table">
    	<!-- Document field -->
        <tr class="user-document-wrap">
            <th><label for="_wcv_custom_settings_doc_example"><?php _e('Document File'); ?></label></th>
            <td><?php printf( '<a href="%1$s" target="_blank" rel="noopener">%1$s</a>', $document_file_url ); ?></td>
        </tr>
        <!-- Image field  -->
         <tr class="user-document-wrap">
            <th><label for="_wcv_custom_settings_image_example"><?php _e('Image File'); ?></label></th>
            <td><?php printf( '<a href="%1$s" target="_blank" rel="noopener">%1$s</a>', $image_file_url ); ?></td>
        </tr>
        <!-- Audio field  -->
         <tr class="user-document-wrap">
            <th><label for="_wcv_custom_settings_audio_example"><?php _e('Audio File'); ?></label></th>
            <td><?php printf( '<a href="%1$s" target="_blank" rel="noopener">%1$s</a>', $audio_file_url ); ?></td>
        </tr>
        <!-- Video field  -->
         <tr class="user-document-wrap">
            <th><label for="_wcv_custom_settings_video_example"><?php _e('Video File'); ?></label></th>
            <td><?php printf( '<a href="%1$s" target="_blank" rel="noopener">%1$s</a>', $video_file_url ); ?></td>
        </tr>
    </table>
<?php
}

Comments

Add a Comment