php - 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
);
解决方案
找到了解决方案。感谢您建议打印...
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',
推荐阅读
- spring - Spring Boot 无法为“null”设置“WARNING”级别
- c# - DbContext:将 null 分配给导航属性时的延迟加载
- arrays - 创建一个函数,使用 postgres 对数组的所有元素一一进行查询
- python-2.7 - 无法在 /usr/lib/Python2.7 中创建站点包,它显示“不允许操作”
- c++ - Running the Visual Studio Profiler from the command line
- javascript - 从列表中单击后如何显示图像?
- ruby-on-rails - 通过避免在 graphql 中进行 N+1 查询来获取 user_profiles
- linux-kernel - 从内核用户空间访问 u-boot 变量
- git - 从 github 中完全删除旧的提交(不仅仅是从历史中)
- sql - Varchar 相等性如何在 SQL 表达式中起作用?