I’ve created a shortcode to fit with id parameters, like this: [edd_user_has_purchased_contrary ids = "10"]
It really works fantastic, however once I put extra id’s it now not works. I would like one thing like this: [edd_user_has_purchased_contrary ids = "10,11"]
Can somebody right my present code?
perform user_has_purchased_contrary( $attributes, $content material = null ) {
$args = shortcode_atts( array( 'ids' => '' ), $attributes, 'edd_user_has_purchased_contrary' );
$downloads = explode( ',', str_replace( ' ', '', $args['ids'] ) );
// If the consumer is logged out, and we aren't involved with logged out customers, do not present the content material
if ( ! is_user_logged_in()) {
if(empty( $downloads )){
return '';
}else{
return $content material;
}
}else{
$user_id = get_current_user_id();
if ( ! edd_has_purchases( $user_id ) ) {
return '';
}
foreach ( $downloads as $obtain ) {
if ( strpos( $obtain, ':' ) ) {
$obtain = explode( ':', $obtain );
$has_purchased = edd_has_user_purchased( $user_id, $obtain[0], $obtain[1] );
} else {
$has_purchased = edd_has_user_purchased( $user_id, $obtain );
}
if ( $has_purchased ){
return '';
}else{
return $content material;
}
}
}
return '';
}
Thanks!