I need assistance compiling a shortcode that exhibits an inventory of customers with a sure function and I’ve to examine if they’ve commented on a sure publish. The publish ID is a parameter of the shortcode.
So as to do that I considered merging this shortcode (made with the assistance of HU is Sebastian) which exhibits for a specified consumer if whether or not or not commented on a sure publish ( [uccount user_id=”” post_id=””] ):
// perform that runs when shortcode is named
perform uccheck_shortcode( $attributes ) {
// Issues that you simply wish to do.
$args = array(
'user_id' => get_the_ID(),
'post_id' => get_the_ID()
);
if( isset( $attributes['post_id'] ) ){
$args['post_id'] = absint($attributes['post_id']);
}
if( isset( $attributes['user_id'] ) ){
$args['user_id'] = absint($attributes['user_id']);
}
$remark = get_comments($args);
if(!empty($remark)){
return '<div class="ccount">YES</div>';
}
else {
return '<div class="ccountniet">NO</div>';
}
return "";
}
// register shortcode
add_shortcode('uccount', 'uccheck_shortcode');
with this that appeared easy to change (I am naive):
perform wcr_list_users($atts) {
// I do not use shortcode_atts as a result of I wish to have a dynamic variety of attributes
$question = new WP_User_Query($atts);
$outcomes = $query->get_results();
// no outcomes
if (empty($outcomes)) {
return;
}
// when we have now outcomes
ob_start();
echo '<ul>';
foreach ($outcomes as $merchandise) {
?>
<li>
<a href="<?php echo get_author_posts_url($item->ID); ?>"> - Electronic mail: <?php echo esc_html($item->display_name); ?></a>
<?php echo esc_html($item->user_email); ?>
</li>
<?php
}
echo '</ul>';
return ob_get_clean();
}
add_shortcode('list_users', 'wcr_list_users');
The purpose is to get a shortcode that works like this: [list_users role=”contributor” orderby=”name” post_id=””] .
If somebody from the neighborhood helps me on this merging it could be lesson for me 🙂
Thanks