• Resolved hamoon

    (@graphirancom)


    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 2 years, 7 months ago by hamoon.
Viewing 8 replies - 1 through 8 (of 8 total)
  • 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 2 years, 7 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 2 years, 7 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]' ); ?>

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘restrict php with edd’ is closed to new replies.