How can I implement a notification system in wordpress?

If you look through the definition of wp_insert_post(), you’ll see do_action( ‘wp_insert_post’, $post_ID, $post, $update ); at the end of it. So you can hook into this and perform whatever task you want to after creating a post. Something like this in your theme’s functions.php or in your plugin file: do_action( ‘wp_insert_post’, ‘send_notification’); function send_notification($post_ID, … Read more

Plugin exceeds memory limit

The code you use also uses WordPress functions that will first load posts (and other relevant data) in memory first and cache them using object cache. So, to delete 100.000 posts, your code will try to load each post in memory and that can take a lot of memory. I am not sure how high … Read more

Sharing common functionality (functions, template parts) between plugins and themes?

The important thing is to make plugin and theme completely functional on their own. Let’s take a look at Codex definition of both theme and plugin: WordPress plugins allow you to easily modify, customize, and enhance a WordPress site. WordPress Themes are files that work together to create the design and functionality of a WordPress … Read more

Redirect traffic to plugin

You can use the init hook to check the $_REQUEST or $_GET super-global variable for your token value and then redirect to pages that are present via WP Core: home_url wp_login_url If you pass additional parameters to these URLs, such as token_valid=true you can use that along with conditional tags like is_front to conditionally display … Read more

How to add a custom tag in contact form 7 and change the output in email?

In the first step, the form to display, you can keep what you have coded. Then you can do that to generate the result in the e-mail : add_filter(“wpcf7_posted_data”, function ($posted_data) { $result = “”; foreach ($posted_data[“tag”] as $index => $question) { $answer = $posted_data[“ans”][$index]; $result .= “$question : $answer\n”; } $posted_data[“my_questions”] = $result; return … Read more