Hide/Show based on Membership (Wordpress)

Discussion in 'Setting-up protection' started by rd2711, Jun 13, 2013.

  1. rd2711

    rd2711 New Member

    Joined:
    Feb 21, 2009
    Messages:
    8
    I run a couple content sites and am in the process of integrating pre-roll advertising on the videos. What I'd like to do is disable ads for paid members. I'm using aMember and Wordpress and the implementation will be inside templates, so shortcodes won't work. I need to do it via PHP. (I am also running the aMember single login plugin.)

    Currently, I use a lot of PHP snippets to hide/show based on db variables:

    <?php if ( get_post_meta($post->ID, 'video_img', true) ) { ?> Insert Video Player <?php } ?>

    What I'd like to do is show/hide a variable in the player based on aMember membership in a similar manner. Or, more specifically, I'm going to hide the code block that enables ads for paid, active members using PHP, so I need a "<?php if" statement that will show up only if there is no valid membership. Can any PHP/aMember gurus help me out?

    Thanks,

    Ryan
  2. rd2711

    rd2711 New Member

    Joined:
    Feb 21, 2009
    Messages:
    8
    Figured it out. Pretty easy, actually.

    <?php if ( !current_user_can('contributor') ) { ?>

    ...ad code here...

    <?php } ?>

Share This Page