shortcode - Get label in user meta query

So I have a function that creates a mailing list of all users that have a specific user meta key checked using shortcode

So I have a function that creates a mailing list of all users that have a specific user meta key checked using shortcode attributes. The function works well but I can't figure out how to display the LABEL instead of the meta key ($args['meta_label'] won't do it and $args['meta_value'] will only show "1" since the field is a true/false button). I have been using ACF when creating the user meta fields.

function mailing_list_shortcode ($atts) {

$args = shortcode_atts(array( 
    'meta_key' => '',
    'meta_value' => '',
    ), $atts );

// The Query
$user_query = new WP_User_Query( $args );

// The Results
$users = $user_query->get_results();
$result = array();

// We have some users that match the conditions
if ( ! empty($users) ) {
    // User Loop
    foreach ( $users as $user ) {
        $result[] = $user->user_email;
    }
    return "<a href=\"mailto:" . implode(',', $result) . "\">" . $args['meta_key'] . "</a>";
    }
}
add_shortcode( 'mailing_list', 'mailing_list_shortcode');

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744715977a4589619.html

相关推荐

  • shortcode - Get label in user meta query

    So I have a function that creates a mailing list of all users that have a specific user meta key checked using shortcode

    20小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信