![]() If( $hook = 'profile.php' || $hook = 'user-edit.php' ) We also changed all default Gravatars with a locally uploaded avatar Load scripts only on the profile page. **Īdd_action( "admin_enqueue_scripts", "ayecode_enqueue" ) We add the function using the action admin_enqueue_scripts. It’s important to load it only on the profile page. Wordpress get media meta code#The following code can be added to your theme’s functions.php file or if you are already using the code snippets plugin, on a new code snippet.ġ) First of all, we need to enqueue the Media Uploader scripts. We wrote this code using WordPress best practices and we’ll use the standard media uploader that ships with WordPress and nothing else. How to change profile picture on WordPress with custom code? If instead, you want some modern code to add to your theme without extra frills and you want to solve all problems related to loading avatars via and forget about updates… the following code is what you are looking for. Wordpress get media meta install#If you don’t have a problem adding yet another plugin on your install to get users to change their profile picture and you need just that, I’d suggest going with The Simple User Avatar plugin. That said, it is by far the most simple and lightweight plugin on the plugin repository to manage avatars. Other than that, this plugin doesn’t allow to replace the default avatar and it will not prevent loading the default avatar from. The Simple User Avatar plugin will add approximately twice as many lines of code (between PHP, CSS, and JS). The main difference is that our code is extremely lightweight with less than 100 lines of code (without comments). This plugin does almost exactly what the code in our tutorial below does. The only plugin that I’ve found that only allow to upload a custom avatar locally and does it in a simple way is the Simple User Avatar plugin. A nice feature, but if you just need your authors to change their profile picture, probably that’s not needed because authors should already have access to the WP backend. Many others will give the option to upload the avatar from the front end too. However, most of them will do a lot more than that and you might not need some or most of their features.Ī lot of them allow you to set a rating for the picture, which can be useful if you are loading the avatar from remote like with .īut it’s not indispensable if you are loading the profile pictures from your local server. There are several plugins that will allow your users to change their profile picture on your WordPress website. How to change profile picture on WordPress via plugin?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |