admin管理员组

文章数量:1389750

I have used custom php form for uploading image via ajax. And has successfully uploaded the image and getting the attachment id & the image url also,

Is there any way to attach the attachment id or the image url to the user profile image, so the admin can also view the user profile image in user list.

Thanks.

I have used custom php form for uploading image via ajax. And has successfully uploaded the image and getting the attachment id & the image url also,

Is there any way to attach the attachment id or the image url to the user profile image, so the admin can also view the user profile image in user list.

Thanks.

Share Improve this question asked Feb 28, 2020 at 6:07 Gaurav ChauhanGaurav Chauhan 113 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

Generally speaking you can add the attachment ID to the user's profile using the User Meta API, then display the image using the show_user_profile and edit_user_profile hooks.

Adding the image to the user listing can be done using the manage_users_columns and manage_users_custom_column filters, which Robert hue covered in this answer: https://wordpress.stackexchange/a/160423/2807

I would use ACF-fields for this. And then add and attachment-ID to the user. This way, you don't have to check if the user has a profile-image or not, so you avoid some annoying dependency-constraint-issues.

If you do so, then you can use the plugin: Admin Columns Pro, to show that in a column in the admin.

本文标签: theme developmentHow can i attach the attachmentID to the user profile image