How to add user defined upload avatar function in WordPress

Friends who use WordPress to build a website should know that WordPress itself does not have the function of uploading a user-defined avatar. If you want to change the avatar, the steps are very troublesome.

In our development of a WordPress theme, especially the multi-user theme, it is necessary for registered users to customize the upload of avatars. Can we add a user-defined upload function in the background of WordPress?

The answer is yes. Here are two user-defined ways to upload avatars.

1. Using the simple local avatars plugin

The webmaster can install it online in the background of WordPress – plugin – search plugin, and directly search the plugin simple local avatars. After it is enabled, he can set his avatar in the dashboard – user – my profile.

2. Pure code implementation

After downloading the simple local avatars plugin, we will find that the whole WordPress plugin is just a file. We can integrate the plugin into the WordPress theme, so that we can use one less plugin.

Plug in download:

link:https://pan.baidu.com/s/1ANon0CKNoOtd-Fhs-g-ldA

Extraction code:ydeb 

usage method

1. Unzip the downloaded compressed package to the theme directory, which is / WP content / themes / your theme/

2. And then in the functions.php Introduction:

//User defined avatar function
include TEMPLATEPATH . '/extends/avatar/simple-local-avatars.php';

After completing the above steps, enter the website background – user – my personal data view, is there a custom upload avatar function?

Function screenshot

Related Article
WordPress displays the registration time of the login user in the frontend

When using WordPress to build a website, some users want to display the user registration time in the frontend, but Read more

WordPress adds the number of SQL queries at the bottom

An excellent woodpress theme is definitely that the less SQL consulting is used, the better. How can we see how Read more

Some WordPress articles can be seen after comments / replies

If we want to hide part of the content of the article and need the user's comments and replies to Read more

WordPress common template function reference document

Basic template filefile namedescribe style.css Theme style file index.php Home page template file header.php Header template file single.php Single article Read more

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image