How does wordpress add the non-editable option to the account's contact information?

Source: Internet
Author: User

For wordpress, account management is relatively low. The background provides a few things: name, gender, and contact information. A personal description can be added at most. Then the other content will be handed over to the WP coders. This function is used by subscribers, authors, and administrators. So in the example of multiple users, if you have to use wordpress, you may have to work hard.

How to customize account contact information

Solagirl has a good article here. You can view it: add new contact information for user information.

The main content is to add new contact methods and remove the built-in ones (AIM, Yahoo IM and Jabber/Google Talk. The main code is as follows:


Add_filter ('User _ contactmethods ', 'My _ user_contactmethods ');
Function my_user_contactmethods ($ user_contactmethods ){
$ User_contactmethods ['QQ'] = 'QQ ';
$ User_contactmethods ['MSN '] = 'MSN ';
Unset ($ user_contactmethods ['aim']);
Unset ($ user_contactmethods ['yim ']);
Unset ($ user_contactmethods ['jabber ']);
Return $ user_contactmethods;
}

Put the above code in function. php. If you want to add other entries, you can write $ user_contactmethods ['keyword'] = 'background display name' in the format and add them in sequence.

The actual result is shown in the figure below.

If you want to call this content elsewhere, you can write

<? Php
$ Current_author = get_userdata (get_query_var ('author '));
Echo $ current_author-> QQ;?>

How to add uneditable content to an account

I thought of two ways: 1. disabled the input box (but it can still be edited after the code is edited); 2. Added the content, which is visible to the administrator.

First, you can use js to handle it, or adjust the input box and add the disabled attribute. The second one is written like this (the basic framework and format are the same as above ):


If (! Isset ($ contactmethods ['Twitter ']) & current_user_can ('create _ users '))
$ Contactmethods ['Twitter '] = 'Twitter ';

If you have the permission to create a new account (administrator), you can edit the hidden entries. The display effect is as follows:

User Perspective

Administrator perspective

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.