• Resolved sueyrad

    (@sueyrad)


    Sorry to bug. I am almost ready to launch my site but just have to get this piece of code modified to show to only PMP “Free”/non members only. user leveles=0,3

    this is the code:

    if ( ! function_exists( 'beAds_By_ID_Input' ) ) {
    
        function beAds_By_ID_Input($randomID){  
    
            /*== Drop-down Value ==*/
    
            $adsdropdown = trim(get_post_meta($randomID, 'meta-box-dropdown', true));
    
            /*== Images ==*/
    
            $imageAdsURL = trim(get_post_meta($randomID, 'be-img-url', true));
    
            /*== HTML ==*/
    
            $htmlAds = get_post_meta($randomID, 'meta-html-code', true);
    
            /*== Video ==*/
    
            $videoAds = get_post_meta($randomID, 'meta-box-text', true);
    
            /*== Check Ads Type ==*/
    
            if($adsdropdown == 'image'){
    
                $beadsimgSrc = get_the_post_thumbnail($randomID, 'full', 'string'); 
    
                $returnValue = '<a href='.$imageAdsURL.' target="_blank">'.$beadsimgSrc.'</a>';
    
            }elseif($adsdropdown == 'html'){
    
                $returnValue = "<div class='betube-html-content'>$htmlAds</div>";
    
            }elseif($adsdropdown == 'video'){           
    
                $returnValue = betube_adv_video_filter($videoAds);
    
            }
    
            return $returnValue;
    
        }
    
    }

    is there a way to make this code only active for those roles mentioned? (0,3)

    Ive tried wrapping in shortcode and tried code like !pmpro_hasMembershipLevel but it keeps breaking site.

    Any clues would be greatly appreciated. once again just need to get this going and ill be ready to start accepting new paid memberships via stripe.

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Jarryd Long

    (@jarryd-long)

    Hi @sueyrad , thank you for reaching out to Paid Memberships Pro.

    You can make use of the pmpro_hasMembershipLevel( 3 ); function to check if the member has that specific level, then show or hide the code below it.

    More information on how this function can be used can be found at https://www.paidmembershipspro.com/documentation/content-controls/require-membership-function/

    Thread Starter sueyrad

    (@sueyrad)

    Am i missing something in here?

    if ( ! function_exists( ‘beAds_By_ID_Input’ ) || !pmpro_hasMembershipLevel(‘Free’)){

    Thread Starter sueyrad

    (@sueyrad)

    I wrapped content but no change, breaks website with this code, code in previous reply doesnt break but shows nothing

    if(pmpro_hasMembershipLevel('0,3'))
    
    {
    
    if ( ! function_exists( 'beAds_By_ID_Input' ) ) {
    
        function beAds_By_ID_Input($randomID){  
    
            /*== Drop-down Value ==*/
    
            $adsdropdown = trim(get_post_meta($randomID, 'meta-box-dropdown', true));
    
            /*== Images ==*/
    
            $imageAdsURL = trim(get_post_meta($randomID, 'be-img-url', true));
    
            /*== HTML ==*/
    
            $htmlAds = get_post_meta($randomID, 'meta-html-code', true);
    
            /*== Video ==*/
    
            $videoAds = get_post_meta($randomID, 'meta-box-text', true);
    
            /*== Check Ads Type ==*/
    
            if($adsdropdown == 'image'){
    
                $beadsimgSrc = get_the_post_thumbnail($randomID, 'full', 'string'); 
    
                $returnValue = '<a href='.$imageAdsURL.' target="_blank">'.$beadsimgSrc.'</a>';
    
            }elseif($adsdropdown == 'html'){
    
                $returnValue = "<div class='betube-html-content'>$htmlAds</div>";
    
            }elseif($adsdropdown == 'video'){           
    
                $returnValue = betube_adv_video_filter($videoAds);
    
            }
    
            return $returnValue;
    
        }
    
    }
    
    }
    • This reply was modified 11 months, 1 week ago by sueyrad.
    Plugin Support Jarryd Long

    (@jarryd-long)

    Checking for multiple levels would require an array used in the pmpro_hasMembershipLevel function. Your code should work with the following if statement:

    if( pmpro_hasMembershipLevel( array( 0, 3 ) ) ) {
    Plugin Support Jarryd Long

    (@jarryd-long)

    Because there have not been any recent updates to this topic, we will be changing the status to resolved.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Wrapping html’ is closed to new replies.