首页 > 解决方案 > Wordpress 插件无法在数组值中提取用户电子邮件变量

问题描述

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

以下代码无法提供任何 Jira 问题。我需要调用登录用户的电子邮件地址并添加到:

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

我还在使用具有 um_fetch_user 功能的 Ultimate Member 插件,我也尝试过但失败了。

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
        );

标签: php

解决方案


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

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',

推荐阅读