Title: restrict php with edd
Last modified: August 15, 2022

---

# restrict php with edd

 *  Resolved [hamoon](https://wordpress.org/support/users/graphirancom/)
 * (@graphirancom)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/restrict-php-with-edd/)
 * hi
    this is the way edd restrict works in page or post : `[edd_restrict id="any"]
   sample restricted text [/edd_restrict]` but i want to use this in a template 
   php and run antoher php like this : `<?php echo do_shortcode( '[edd_restrict 
   id="any"]<?php include(TEMPLATEPATH."/post-ads.php");?>[/edd_restrict]' );?>`
   this way it hide the postads.php from non buyers but after buying a product it
   can not run and show the php inside the postads.php how can i do that? why there
   is no php function to use edd restrict in template? paid membership pro have 
   a php code for restriction bud edd dont !
    -  This topic was modified 3 years, 10 months ago by [hamoon](https://wordpress.org/support/users/graphirancom/).

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

 *  [Pratik Jain](https://wordpress.org/support/users/pratik-jain/)
 * (@pratik-jain)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/restrict-php-with-edd/#post-15919432)
 * Hi [@graphirancom](https://wordpress.org/support/users/graphirancom/)
 * Thanks for providing the shortcode. I have checked it and we can not include 
   PHP file like this. You have to create the another shortcode and put it inside
   the main shortcode.
 * Kindly add below function in your theme functions.php file
 *     ```
       function edd_run_mycode( $atts, $content = null ) {
   
       	extract( shortcode_atts( array(
       									'file' => null,
       								), $atts, 'edd_run_mycode' )
       	);
   
       	ob_start();
   
       	if( $file ) {
       		include( $file );
       	}
   
       	$content .= ob_get_clean();
       }
       add_shortcode('edd_run_mycode', 'edd_run_mycode');
       ```
   
 * Also you can use shortcode like below
 * `<?php echo do_shortcode( '[edd_restrict id="any"][edd_run_mycode file="'.TEMPLATEPATH.'/
   post-ads.php"][/edd_restrict]' ); ?>`
 * I hope it will help you.
 *  Thread Starter [hamoon](https://wordpress.org/support/users/graphirancom/)
 * (@graphirancom)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/restrict-php-with-edd/#post-15919641)
 * again not working. it can not run the php…shows nothing
    -  This reply was modified 3 years, 10 months ago by [hamoon](https://wordpress.org/support/users/graphirancom/).
 *  [Pratik Jain](https://wordpress.org/support/users/pratik-jain/)
 * (@pratik-jain)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/restrict-php-with-edd/#post-15920763)
 * Hi [@graphirancom](https://wordpress.org/support/users/graphirancom/)
 * It should work. I have double checked the code and I did not find anything in
   that.
 * Can you please provide me the exact shortcode which you are using in a page template?
 * I think [edd_restrict id=”any”] is not working at your side. You have to provide
   the relevant numeric ID.
 *  Thread Starter [hamoon](https://wordpress.org/support/users/graphirancom/)
 * (@graphirancom)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/restrict-php-with-edd/#post-15920873)
 * No edd restric any works when i out text ibstead of php. And <?php include(TEMPLATEPATH.”/
   post-ads.php”);?> Works too outside php echo
 *  Thread Starter [hamoon](https://wordpress.org/support/users/graphirancom/)
 * (@graphirancom)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/restrict-php-with-edd/#post-15920882)
 * You know edd restric shordcode is for edd restrict addon for edd . You talking
   about edd itself? If edd have restric feature fir pho what is restrict content
   addon?
 *  [Pratik Jain](https://wordpress.org/support/users/pratik-jain/)
 * (@pratik-jain)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/restrict-php-with-edd/#post-15937098)
 * Hi [@graphirancom](https://wordpress.org/support/users/graphirancom/)
 * Yes, `edd_restrict` is a part of EDD restrict content addon.
 * Can you please verify that below shortcode is working or not? Can you see the
   output ‘Hi, This is a test…’?
 * `<?php echo do_shortcode( '[edd_restrict id="any"]Hi, This is a test...[/edd_restrict]');?
   >`
 * I have just removed the inner shortcode and placed the text. Please check that
   it is working or not.
    -  This reply was modified 3 years, 9 months ago by [Pratik Jain](https://wordpress.org/support/users/pratik-jain/).
 *  Thread Starter [hamoon](https://wordpress.org/support/users/graphirancom/)
 * (@graphirancom)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/restrict-php-with-edd/#post-15937221)
 * It works when its a text. And i found a shortcode for edd all access Which works
   with html too. But not with php. When it’s php , it can hide it but after buying
   prodct nothing shows
 *  [Pratik Jain](https://wordpress.org/support/users/pratik-jain/)
 * (@pratik-jain)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/restrict-php-with-edd/#post-15949450)
 * Hi [@graphirancom](https://wordpress.org/support/users/graphirancom/)
 * I am little bit confused. When you have used below shortcode then does your `
   post-ads.php` file is executed? Have you checked it by echo something in that
   file?
 * `<?php echo do_shortcode( '[edd_restrict id="any"][edd_run_mycode file="'.TEMPLATEPATH.'/
   post-ads.php"][/edd_restrict]' ); ?>`

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

The topic ‘restrict php with edd’ is closed to new replies.

 * ![](https://ps.w.org/easy-digital-downloads/assets/icon.svg?rev=3455837)
 * [Easy Digital Downloads – eCommerce Payments and Subscriptions made easy](https://wordpress.org/plugins/easy-digital-downloads/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/easy-digital-downloads/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/easy-digital-downloads/)
 * [Active Topics](https://wordpress.org/support/plugin/easy-digital-downloads/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/easy-digital-downloads/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/easy-digital-downloads/reviews/)

## Tags

 * [EDD](https://wordpress.org/support/topic-tag/edd/)

 * 11 replies
 * 2 participants
 * Last reply from: [Pratik Jain](https://wordpress.org/support/users/pratik-jain/)
 * Last activity: [3 years, 9 months ago](https://wordpress.org/support/topic/restrict-php-with-edd/#post-15949450)
 * Status: resolved