Your code should be the good one. You just have to use is_user_logged_in() into a hook instead of calling it directly, and probably to early.
function wp_se_339916() {
if ( is_user_logged_in() {
add_filter( 'wordads_excerpt_disable', '__return_true' );
add_filter( 'wordads_content_disable', '__return_true' );
add_filter( 'wordads_inpost_disable', '__return_true' );
add_filter( 'wordads_header_disable', '__return_true' );
}
}
add_action( 'template_redirect', 'wp_se_339916' );
Using the template_redirect hook could be a good solution. You’ll just have to paste this into your functions.php file. https://developer.wordpress.org/reference/functions/is_user_logged_in/
Related Posts:
- How to disable Jetpack modules such as Stats?
- Cannot activate Jetpack on my server
- Jetpack Infinite Scrolling For Multiple Columns On Same Page?
- Popular posts by view with Jetpack
- Gravatar Hovercards (Jetpack) jQuery error
- Jetpack – stats_get_csv period parameter
- Using stats_get_csv to return a list of popular posts by views with thumbnails
- How do I update the site URL used by Jetpack subscribe widget [closed]
- Isotope with Infinite Scroll
- Jetpack infinite scroll not working on Twenty Twelve [closed]
- Can’t connect to my WordPress website using Windows 8 app?
- What does this number represent in JetPack stats? [closed]
- I have a self hosted blog but now the WordPress.com stats plugin has stopped working
- jetpack suddendly stopped working [closed]
- Jetpack social icons in other places on site
- Why I can’t modified jetpack default blank.jpg on og:image?
- How to remove WordPress’ Jetpack plugin completely? [duplicate]
- How do I remove quantcast from my sites?
- Customizing JetPack Publicize Sharing
- Jetpack infinite scroll not working on twentysixteen custom theme
- Change $content_width based on screen size (functions.php)
- Jetpack button location buffering [closed]
- Does Jetpack conflicts with load_template()?
- Hide Jetpack for Contributor [closed]
- How do i import email addresses into WordPress.com subscriptions? [closed]
- Jetpack Infinite Scroll – changing number of posts
- How to allow users to write jetpack custom post types? [closed]
- Missing Jetpack Contact Form button when running locally [closed]
- Why does Jetpack insert it’s script outside the tag?
- Updating shortlinks from staging [closed]
- Jetpack Publicize and Android
- How can I get the Jetpack Image plugin to open links in a new window? [closed]
- Infinite Scroll on Self-hosted WordPress [closed]
- How to remove Stats by jetpack dashboard widget?
- Publicize in Jetpack stopped working on Custom Post Type it works in Blog Posts
- Jetpack Top post widget (display post views)
- Unable to setup jetpack on my site
- Where does Jetpack store markdown?
- The plugin jetpack/jetpack.php has been deactivated due to an error: Plugin file does not exist
- Jetpack URL shortening, fixing after website URL change
- Infinite scroll function for Twenty Seventeen
- how to disable jetpack for non admins?
- Popular posts – based on pageviews
- Implementing backbone.js to retrieve category posts using JSON API
- Jetpack email sharing button to include image on email sent
- Is there a way to enable a Jetpack module via `functions.php`
- Pageview confusion [closed]
- Jetpack Infinite Scroll, Isotope and ImagesLoaded
- Force Jetpack to not use og:image tag for favicon / Site Icon [closed]
- Using Jetpack to track an Ajax powered blog [closed]
- Jetpack: Access visitor stats in templete
- Generate Sitemap after removing JetPack
- Jetpack Running Locally [closed]
- How to tell if Jetpack’s Photon is active?
- Custom Loop and Infinite Scroll
- Moving sharedaddy buttons (in Jetpack) to the top of a post?
- Is there a way to fire other functions from wp_insert_post
- Custom post metadata not appearing in public API
- Placeholders in Jetpack Contact Form [closed]
- Jetpack Blog Subscriptions on Multisite [closed]
- Jetpack Infinite scroll conflicting with theme’s pre_get_posts custom posts_per_page
- How can I remove the new stats message? [closed]
- JetPack Infinite Scroll not working on custom theme
- Is it safe to delete uploaded photos if Photon (Jetpack) is activated?
- Removing the main link to Jetpack from the menu
- Child Theme vs. Jetpack Editor
- stats_get_csv (WordPress Stats) to only display top posts (not pages)
- Removal of Jetpack OG Tags from old blog site
- Exclude Post Type from Jetpack Infinite Scroll
- Jetpack Infinite Scroll – Add more than 7 posts each time?
- Jetpack Comments with fall-back
- Adding character count and limit in comments, modifying labels and fields – jetpack
- Jetpack “Connect to WordPress” serving insecure content under HTTPS
- Filtering get_permalink in Jetpack / ShareDaddy
- Why does akismet prevent jetpack comments from appearing in my moderation queue? [closed]
- How to disable or hide WordPress.com as a social media login option for Jetpack Comments [closed]
- Redirect to another page using contact form 7? [closed]
- Remove “show sharing buttons” metabox Jetpack from custom post type
- Jetpack could not contact wordpress [closed]
- Remove Jetpack infinite-wrap
- Jetpack JSON API configure button not showing [closed]
- Jetpack stats and caching strategy [closed]
- Facebook and Twitter share buttons not working [closed]
- WordPress Stats Plugin: Display Post Views [closed]
- Jetpack: Subscribe via e-mail [closed]
- Failed to import “File name”: Invalid post type jetpack-portfolio
- Show views count for pop up post
- What is the difference between `Home page / Archieves` and the page set as homepage?
- i1.wp.com url problem (Jetpack not installed)
- the_content filter not working when Jetpack activated. Any idea?
- How can I disable Jetpack plugin on mobile?
- Jetpack Infinite Scroll Not Working
- basic wordpress api endpoint to serve a key-value dictionary
- Comments template only linking to one post
- Visual Editor not working when Jetpack plugin is active
- Infinite scroll loads new posts several times
- I’ve installed Jetpack but can’t edit the CSS to my blog?
- Force Jetpack to use og:url with http on an https website
- query posts only works on the first page
- Failed to import File_name Invalid post type jp_pay_product