Title: php echo inside echo shortcode. php code role management
Last modified: August 30, 2016

---

# php echo inside echo shortcode. php code role management

 *  Resolved [byjuststar](https://wordpress.org/support/users/byjuststar/)
 * (@byjuststar)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/php-echo-inside-echo-shortcode-php-code-role-management/)
 * Hello: I am using code
 *     ```
       <?php if( $theme_usage == 'all' || $theme_usage == 'coupons' ): ?>
                           					<li class="<?php echo $subpage == 'my_coupons' ? 'active' : '' ?>">
                           						<a href="<?php echo esc_url( couponxl_append_query_string( $permalink, array( 'subpage' => 'my_coupons' ), array( 'all' ) ) ); ?>">
                           							<h4><?php _e( 'My Coupons', 'couponxl' ) ?></h4>
                           							<p><small><?php _e( 'Check here coupons you have submitted or add new one', 'couponxl' ) ?></small></p>
                           						</a>
                           					</li>
                                           <?php endif; ?>
                                           <?php if( $theme_usage == 'all' || $theme_usage == 'deals' ): ?>
                           					<li class="<?php echo $subpage == 'my_deals' ? 'active' : '' ?>">
                           						<a href="<?php echo esc_url( couponxl_append_query_string( $permalink, array( 'subpage' => 'my_deals' ), array( 'all' ) ) ); ?>">
                           							<h4><?php _e( 'My Deals', 'couponxl' ) ?></h4>
                           							<p><small><?php _e( 'Check here deals you have submitted or add new one', 'couponxl' ) ?></small></p>
                           						</a>
                           					</li>
                                           <?php endif; ?>
       ```
   
 * I am need shordcode:
 * `<?php echo do_shortcode('[private role="administrator"]Text for Administrators[/
   private]') ?>`
 * And I am need working code:
 *     ```
       <?php echo do_shortcode('[private role="administrator"]' , '
       <?php if( $theme_usage == 'all' || $theme_usage == 'coupons' ): ?>
                           					<li class="<?php echo $subpage == 'my_coupons' ? 'active' : '' ?>">
                           						<a href="<?php echo esc_url( couponxl_append_query_string( $permalink, array( 'subpage' => 'my_coupons' ), array( 'all' ) ) ); ?>">
                           							<h4><?php _e( 'My Coupons', 'couponxl' ) ?></h4>
                           							<p><small><?php _e( 'Check here coupons you have submitted or add new one', 'couponxl' ) ?></small></p>
                           						</a>
                           					</li>
                                           <?php endif; ?>
                                           <?php if( $theme_usage == 'all' || $theme_usage == 'deals' ): ?>
                           					<li class="<?php echo $subpage == 'my_deals' ? 'active' : '' ?>">
                           						<a href="<?php echo esc_url( couponxl_append_query_string( $permalink, array( 'subpage' => 'my_deals' ), array( 'all' ) ) ); ?>">
                           							<h4><?php _e( 'My Deals', 'couponxl' ) ?></h4>
                           							<p><small><?php _e( 'Check here deals you have submitted or add new one', 'couponxl' ) ?></small></p>
                           						</a>
                           					</li>
                                           <?php endif; ?>
       ' , '[/private]') ?>
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/php-echo-inside-echo-shortcode-php-code-role-management/#post-6340789)
 * you might need to ‘assemble’ whatever string you need for within the `do_shortcode()`
   function;
 * example (untested):
 *     ```
       <?php
       $string = '[private role="administrator"]';
       if( $theme_usage == 'all' || $theme_usage == 'coupons' ):
       	$string .= '<li class="' . ( $subpage == 'my_coupons' ? 'active' : '' ) . '">
       	<a href="' . esc_url( couponxl_append_query_string( $permalink, array( 'subpage' => 'my_coupons' ), array( 'all' ) ) ) . '">
       	<h4>' . __( 'My Coupons', 'couponxl' ) . '</h4>
       	<p><small>' . __( 'Check here coupons you have submitted or add new one', 'couponxl' ) . '</small></p>
       	</a>
       	</li>';
       endif;
       if( $theme_usage == 'all' || $theme_usage == 'deals' ):
       	$string .= '<li class="' . ( $subpage == 'my_deals' ? 'active' : '' ) . '">
       	<a href="' . esc_url( couponxl_append_query_string( $permalink, array( 'subpage' => 'my_deals' ), array( 'all' ) ) ) . '">
       	<h4>' . __( 'My Deals', 'couponxl' ) . '</h4>
       	<p><small>' . __( 'Check here deals you have submitted or add new one', 'couponxl' ) . '</small></p>
       	</a>
       	</li>';
       endif;
       $string .= '[/private]';
       echo do_shortcode( $string );
       ?>
       ```
   
 *  Thread Starter [byjuststar](https://wordpress.org/support/users/byjuststar/)
 * (@byjuststar)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/php-echo-inside-echo-shortcode-php-code-role-management/#post-6340804)
 * Thank you very much alchymyth. best regards

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘php echo inside echo shortcode. php code role management’ is closed to
new replies.

## Tags

 * [Role Management](https://wordpress.org/support/topic-tag/role-management/)

 * 2 replies
 * 2 participants
 * Last reply from: [byjuststar](https://wordpress.org/support/users/byjuststar/)
 * Last activity: [10 years, 8 months ago](https://wordpress.org/support/topic/php-echo-inside-echo-shortcode-php-code-role-management/#post-6340804)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
