Title: Add php inside the shortcode?
Last modified: September 14, 2021

---

# Add php inside the shortcode?

 *  Resolved [aaronrobb](https://wordpress.org/support/users/aaronrobb/)
 * (@aaronrobb)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/add-php-inside-the-shortcode/)
 * I’m using the shortcode within my template file using the normal do_shortcode
   but was wondering how I could add php to the protected content? Basically i want
   to load a “get_template_part()” inside the shortcode since the content that is
   protected is coded and not just wysiwyg text.
 * Is there a good way to do that?

Viewing 1 replies (of 1 total)

 *  Thread Starter [aaronrobb](https://wordpress.org/support/users/aaronrobb/)
 * (@aaronrobb)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/add-php-inside-the-shortcode/#post-14872685)
 * Update: Just used the “if ( current_user_can( ‘capability_name’ ) )” snippet 
   and that works fine with a custom capability for a custom role.

Viewing 1 replies (of 1 total)

The topic ‘Add php inside the shortcode?’ is closed to new replies.

 * ![](https://ps.w.org/members/assets/icon-256x256.png?rev=3508404)
 * [Members - Membership & User Role Editor Plugin](https://wordpress.org/plugins/members/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/members/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/members/)
 * [Active Topics](https://wordpress.org/support/plugin/members/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/members/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/members/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [aaronrobb](https://wordpress.org/support/users/aaronrobb/)
 * Last activity: [4 years, 8 months ago](https://wordpress.org/support/topic/add-php-inside-the-shortcode/#post-14872685)
 * Status: resolved