【问题标题】:Is this insert possible in function: author meta into a different string?这是否可以在函数中插入:作者元到不同的字符串?
【发布时间】:2017-11-15 13:51:54
【问题描述】:

我需要建议。插件开发人员向我提供了以下代码,以便将捐赠表格插入单个帖子模板,但我需要贝宝地址通过作者元自动引入帖子作者的电子邮件地址。这可能吗?

function multiple_paypal_accounts( $paypal_args, $payment_data ) {
    $form_id = isset( $payment_data['post_data']['the-form-id'] ) ? $payment_data['post_data']['the-form-id'] : '';
    if('3830' === $form_id ) {
        // Here I want to customize the email address to show the post author's paypal email address
        $paypal_args['business'] = 'THIS IS WHERE I NEED TO PULL IN THE PAYPAL ADDRESS FROM AUTHOR META DATA';
    }
    // Always return the paypal args.
    return $paypal_args;
}
add_filter( 'the_form_paypal_redirect_args', 'multiple_paypal_accounts', 10, 2 );

【问题讨论】:

  • 我的猜测是:global $post; $author_id=$post->post_author; $author_email = get_the_author_meta('email', $author_id );

标签: php wordpress function author


【解决方案1】:

如果我理解这个问题,表单接受 GET 和 POST 参数,并且看起来变量 $payment_data 的使用如下:$payment_data['post_data'][?]。这似乎可能包含此信息。 $payment_data['post_data']['email'] 是一个大胆的猜测,但可能不正确。

如果正确,您可以像这样左分配:$paypal_args['business'] = $payment_data['post_data']['email'];

如果没有,您可以执行 $payment_data['post_data'] 的 var_dump() 来找出该变量可能包含的内容。更多信息:http://php.net/manual/en/function.var-dump.php

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-30
    • 2021-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-08
    相关资源
    最近更新 更多