Hi @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
(@graphirancom)
again not working. it can not run the php…shows nothing
-
This reply was modified 3 years, 9 months ago by
hamoon.
Hi @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
(@graphirancom)
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
(@graphirancom)
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?
Hi @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.
Thread Starter
hamoon
(@graphirancom)
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
Hi @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]' ); ?>