How to Add PHP Script into a Shortcode with Open and Close Brackets?

I have the following code in a plug-in on a .php file…but I only want it to be seen by people in a certain group. So, for this, I usually use Groups for WordPress…and I put the shortcode brackets around what I want to hide/show. But, as you’ll see, this code has php, and then, when I put the following code in the shortcode brackets, I get an error.

So, I have the following code I want to show only to group members:

<div>
<?php
$is_in_cart = ccb_is_product_in_cart();
$checked = ”;
if( $is_in_cart ) {
$checked = ‘checked=”checked”‘;
}
printf(
‘<input type=”checkbox” data-product-id=”%s” name=”ccb_bump_checkbox” id=”ccb_bump_checkbox” %s value=”1″>’,
ccb_get_bump_product_id(),
$checked
); ?>
<?php printf(
‘<label style=”” for=”ccb_bump_checkbox”>%s</label>’,
ccb_get_bump_label()

); ?>

And I need to put it inside this shortcode on a .php:

<?php echo do_shortcode(‘[groups_member group=”yes”]

Needs to go here……so only group members can see it…

[/groups_member]’); ?>

How can I do this?

Thank you,

EVAN

Read more here:: How to Add PHP Script into a Shortcode with Open and Close Brackets?

Leave a Reply

Your email address will not be published. Required fields are marked *