Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wp-user-manager/381fb66ec8608f31c5c868ff62143845 to your computer and use it in GitHub Desktop.
Save wp-user-manager/381fb66ec8608f31c5c868ff62143845 to your computer and use it in GitHub Desktop.
WP User Manager - Show the user submitted videos in the edit-user admin screen of WordPress
<?php
add_filter( 'wpumcf_user_carbon_field', function ( $carbon_field, $field ) {
if ( $field->get_type() !== 'video' ) {
return $carbon_field;
}
global $pagenow;
$user_id = false;
if ( $pagenow === 'profile.php' ) {
$user_id = get_current_user_id();
}
if ( isset( $_GET['user_id'] ) ) {
$user_id = filter_input( INPUT_GET, 'user_id', FILTER_VALIDATE_INT );
}
if ( ! $user_id ) {
return $carbon_field;
}
$value = get_user_meta( $user_id, $field->get_meta( 'user_meta_key' ), true );
if ( ! $value ) {
return $carbon_field;
}
if ( is_numeric( $value ) ) {
$image_src = wp_get_attachment_url( absint( $value ) );
} elseif ( is_array( $value ) && isset( $value['url'] ) ) {
$image_src = $value['url'];
} else {
$image_src = $value;
}
$text = '<span class="wpum-uploaded-file-name">' . wp_video_shortcode( array( 'src' => $image_src ) ) . '</span>';
$carbon_field->set_help_text( $text );
return $carbon_field;
}, 10, 2 );
@wp-user-manager
Copy link
Author

Required Custom Fields v2.5.1.

Save this file to your /wp-content/mu-plugins/ directory (you might need to create the mu-plugins directory).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment