切片发票联系表7扩展名:如何填充名字和姓氏字段?

时间:2019-02-01 00:39:43

标签: php wordpress contact-form-7

如何填充名字和姓氏字段(不仅是sliced_invoices_name字段)?

插件

1 个答案:

答案 0 :(得分:0)

只需发布一种解决方案即可在切片发票联系表7扩展名中为用户添加姓氏和名字:

wp-content\plugins\sliced-invoices-contact-form-7\sliced-invoices-contact-form-7.php

更改:

$name = $posted_data['sliced_client_name']; //在create_new_quote($ posted_data)

收件人:

$fname   = $posted_data['sliced_client_fname']; /* REPLACE 'sliced_client_fname' WITH YOUR FIELD NAME IN THE FORM FOR FIRST NAME*/
$lname   = $posted_data['sliced_client_lname']; /* REPLACE 'sliced_client_lname' YOUR FIELD NAME IN THE FORM FOR LAST NAME*/
$name    = $fname . " " . $lname;

添加fnamelname行:

$client_array = array(
    'name'          => trim( $name ),
    'fname'         => $fname, /* ADDED */
    'lname'         => $lname, /* ADDED */

maybe_add_client( $client_array )

添加:

// create the user
$userdata = array(
    'user_login'  =>  $name,
    'first_name'  =>  $client_array['fname'], /* ADDED */
    'last_name'   =>  $client_array['lname'], /* ADDED */

现在,您可以在“编辑客户端”和“编辑个人资料”视图中看到填充的名字和姓氏字段。

WordPress Codex指定了WordPress用户可以拥有的所有字段(用于wp_insert_user()函数)。

干杯, 菲比