WordPress插件无法提取数组值中的用户电子邮件变量

时间:2019-05-17 15:45:34

标签: php

编辑不再受支持的WordPress插件,该插件几乎具有我需要的功能。 CRANE APP Jira Integration插件允许您使用简码在页面上显示Jira问题表。简码的属性之一在Jira中定义了通过JQL(Jira查询语言)显示哪些问题。我的目标是编辑插件,以便当前登录用户的电子邮件包含在插件的JQL语句中。希望登录的任何人都可以在页面上看到他们报告的所有问题。

以下代码无法传递任何Jira问题。我需要拨打已登录用户的电子邮件地址,并将其添加到:

array ( 'jql' => 'reporter = $user_email AND...

我还在使用Ultimate Member插件,该插件具有um_fetch_user函数,我也曾尝试并失败了。

function ca_ji_shortcodes_init() {

    // pulling in user

    add_action('wp_loaded', function() {

  // stuff here where you get user id

  $user_data = get_userdata( $userid );

  // stuff here
  um_fetch_user( get_current_user_id() );
        $email = um_user('user_email');

});

    // Adding shortcode for default Jira integration
    function ca_ji_shortcode_default( $atts, $content, $tag ) {
        // Normalizing attribute keys
        $atts = array_change_key_case( ( array ) $atts, CASE_LOWER );
        // Overriding default attributes
        $atts = shortcode_atts(
            array(
                'jql' => 'reporter = '.$user_data->user_email.' AND resolution = unresolved ORDER BY updated DESC',
                'col_fields' => 'status,summary',
                'col_labels' => __( 'Status', 'crane-app-jira-integration' ) . ',' . __( 'Summary', 'crane-app-jira-integration' ),
                'more_fields' => 'summary,description',
                'more_labels' => __( 'Summary', 'crane-app-jira-integration' ) . ',' . __( 'Description', 'crane-app-jira-integration' )
            ),
            $atts,
            $tag
        );

1 个答案:

答案 0 :(得分:0)

找到了解决方案。感谢您建议打印...

function ca_ji_shortcodes_init() {


// Adding shortcode for default Jira integration
function ca_ji_shortcode_default( $atts, $content, $tag ) {
    global $current_user;
    get_currentuserinfo();
    // Normalizing attribute keys
    $atts = array_change_key_case( ( array ) $atts, CASE_LOWER );
    // Overriding default attributes
    $atts = shortcode_atts(
        array(
            'jql' => 'reporter = \'' . $current_user->user_email . '\' AND resolution = unresolved ORDER BY updated DESC',