WordPress adds contact fields such as Sina Tencent Weibo to users

Source: Internet
Author: User
Tags comments php file wordpress version

WordPress adds contact fields such as Sina Tencent Weibo to users. The following code adds three contact methods: Sina Weibo, Tencent Weibo, and iMessage. You can also modify or add the fields you need. Paste the following code to the functions. php file of the current topic. After saving the code, you can see the effect in the contact information in the background> user> my personal data.

The code is as follows: Copy code

Add_filter ('User _ contactmethods ', 'My _ user_contactmethods ');
Function my_user_contactmethods ($ user_contactmethods ){
$ User_contactmethods ['Weibo '] = 'sina weibo ';
$ User_contactmethods ['T-QQ'] = 'Tencent Weibo ';
$ User_contactmethods ['imessage'] = 'imessage ';
Return $ user_contactmethods;
}

If you want to add more information, you can add it in the form of $ user_contactmethods ['qq-weibo '] = 'Tencent weibo. Qq-weibo is a character segment and must be unique. Tencent Weibo is the name of this option.

Synchronous recommendation of Sina, Tencent, Weibo, NetEase Weibo and Douban plug-ins


1. Check that the comment template contains <? Php do_action ('comment _ form', $ post-> ID);?> Code. If not, add it.

2. wordpress version> 3.0.

3. to synchronize comments to Weibo, a = confirmation field is required, that is, the "synchronize to XXX" option selected after login, when submitting your ajax comments, you must also extract and submit the value of this field. The method is as follows:

PHP
// Native javascript method

The code is as follows: Copy code


If (document. getElementById ('post _ to_socialmedias ') & amp; document. getElementById ('post _ to_socialmedias'). checked ){

 

// Here, field information is appended to the end of the original submission string, and submit_str is the assumption that the original submission string

 

Submit_str + = '& amp; post_to_socialmedias =' + document. getElementById ('post _ to_socialmedias '). value;

 

}

 

PHP

1 // jQuery method

The code is as follows: Copy code


If ($ ('# post_to_socialmedias'). length & gt; 0 ){


Submit_str + = '& amp; post_to_socialmedias =' + $ ('# post_to_socialmedias: checked'). val ();


}

4. to modify an article, synchronize it to Weibo again, find the "force sync to Weibo" option at the bottom of the article editing page, and select "synchronize ", when you modify an article, the modified information is synchronized to Weibo.

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.