- This topic has 7 replies, 2 voices, and was last updated 3 years, 4 months ago by .
-
Topic
-
Hello,
I am trying to add a field in the add new user screen in backend using the “user_new_form” action hook. I just want to use the media upload manager of wordpress as you do.
My code is this:
<tr class="form-field"> <th scope="row"><label for="andydote_brand_image"><?php esc_html_e( 'Logo', 'andydote-eshop-plugin' ) ?> </label></th> <td> <img />' height='100'> <input id="upload_brand_image_button" type="button" class="button" value="<?php esc_html_e( 'Add Media', 'andydote-eshop-plugin' ); ?>" /> <input type='hidden' name='andydote_brand_image' id='andydote_brand_image' value='<?php echo get_option( 'media_selector_attachment_id' ); ?>'> <input type="submit" name="submit_image_selector" value="Save" class="button-primary"> </td> </tr>
Then I save the field like this:
if ( isset( $_POST['submit_image_selector'] ) && isset( $_POST['andydote_brand_image'] ) ) { update_user_meta( 'media_selector_attachment_id', absint( $_POST['andydote_brand_image'] ) ); }
Well the problem is that when I hit “add new user” in order to save the user, when I go to the user details in the backend your plugin does not show the image I saved.
The code for creating a new user meta field is this:
array( 'name' => esc_html__( 'Logo', 'andydote-eshop-plugin' ), 'id' => $prefix . 'brand_image', 'type' => 'image_advanced', ),
Is there any way to use your code somehow or instead we should find out why although I save the image in the add new user screen, it does not show up in the user details screen ( user-edit.php ).
Hope I am clear 🙂
Thank you in advance.
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- You must be logged in to reply to this topic.