• Could you help me finish this php script to hide ads for subscribers?
    I have targeted the ad above but I need to target the 2 ads at the end of posts.
    Also I’m not sure for the action if I’m right. I found this script that is supposed to hide admin bar for non administrator. I got inspired.

    Many thanks.

    function habfna_hide_adverts()
    {
    ?>
    <style type=”text/css”>
    .wpcnt .wpcnt-header {
    display: none;
    }
    </style>
    <?php
    }
    function habfna_disable_admin_bar()
    {
    if(!current_user_can(‘subscriber’))
    {
    // add_filter( ‘show_admin_bar’, ‘__return_false’ );
    add_action( ‘admin_print_scripts-profile.php’, ‘habfna_hide_adverts’ );
    }
    }
    add_action(‘init’, ‘habfna_disable_admin_bar’, 9);

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • You could wrap your ads in something like this:

    <?php if( current_user_can('subscriber') || current_user_can('administrator') ) {  ?>
        // user is a subscriber or administrator, do nothing, or something it's up to you
    <?php } else { ?>
       // ad code goes here
    <?php } ?>
    
    Thread Starter na1man

    (@na1man)

    in fact it’s only supposed to hide ads for subscriber. administrator shouldn’t have to be mentioned. ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘hide adverts for subscribers’ is closed to new replies.