Can I “protect” a page with a form asking for an email address?

What about filtering the_content? function se365701_require_email ( $content ) { if ( is_page( ‘require_email’ ) ) && !isset( htmlspecialchars( $_COOKIE[‘submitted_email’]) ) { return $form; // your MailChimp Form Code } else{ return $content; } add_filter( ‘the_content’, ‘se365701_require_email’ ); Note that your form provide itself may have a cookie or you may need to set it … Read more

Hook for changing excerpt content when excerpt not set

The proper hooks for modifying the post excerpt are the ones you already tried: get_the_excerpt and the_excerpt, and WordPress actually uses the former one to generate an excerpt from the full post content, if there’s no custom or manually-specified excerpt for the post — below is the relevant code in wp-includes/default-filters.php: add_filter( ‘get_the_excerpt’, ‘wp_trim_excerpt’, 10, … Read more

Remove Header and Footer if user is not logged on

You have a lot of ways to do this. The first important thing is next: You must have a header or a footer (default header and footer, from WP) if you want to have functionality. E.g If you are loaded scripts or styles in function.php they will be broken, because you can’t load them without … Read more

Modify existing plugin function with add_filter

So you’re half way there with the code you have, you’re only missing a small part which is that your filter function takes information about what it’s filtering through function parameters, can then make changes to the thing that’s being filtered (or not) and then must pass that back out (return it). I.e. In this … Read more

Change the Default Plugin page filter to Active intead of All

There is no WordPress hook to filter the current status on the plugins admin, but if you must, you can use $_REQUEST[‘plugin_status’] to change the default status. See example below where I use the load-plugins.php hook to ensure we’re changing the status (or modifying the superglobal $_REQUEST) only on the plugins.php page: function wpse_373622() { … Read more

What are admin hooks

The init hook is triggered a little earlier than the admin_init. Between them is triggered wp_loaded and few hooks related to updating the DB. The init hook fires when WP is finished loading (viewer-facing and administration side). The admin_init hook fires on administration side only (/wp-admin/*), therefore is triggered also by front- and back-end ajax … Read more