You can register multiple activation hooks, that’s not a problem. Or you can use a wrapper function that calls the other functions.
What is wrong, is this:
add_action( 'template_include', 'terms_redirect' );
template_include
is a filter, not an action, so you should use add_filter()
.
$author_id = 1;
is dangerous, there might be no author with that id. Who owns that page then? Use get_current_user_id()
instead.
get_page_by_title( $title )
is not good enough for a check. What happens if the slug is already in use?
Related Posts:
- How to redirect to settings page once the plugin is activated?
- How to output message during plugin activation
- Prevent network activation of plugin
- Inserting Taxonomy Terms During a Plugin Activation?
- Using wp_cron with custom time interval and the register activation hook
- Call activation hook multiple times
- Only allow plugin to be activated on root site of multisite
- why creating tables using $wpdb is not being executed while installing plugins?
- Override pluggable functions in a plugin?
- Plugin activation error due to unexpected output
- Settings not set after calling register_setting()
- Insert terms for custom taxonomy on plugin activation, or each page load (init hook)
- How to stop activation addon if the main plugin is not activated
- Add Link Category on Activation?
- WordPress Plugin Activate / Deactive Failing
- Multiple array for post_content on plugin activation
- Class cannot be found, but it’s available in the file, I get: Fatal Error: Uncaught Error: Class ‘Blocks\Base\Activation’ not found
- Plugin can’t be activated [closed]
- Clean way to initialize plugin in newly-added site when plugin has been network activated?
- WordPress Fatal error: Uncaught Error: Call to undefined function dbDelta()
- Custom Plugin activation error in Multisite
- How to store in the database directly the translation?
- Unable to show a message after plugin activation
- Refresh or redirect page after activate my plugin
- I can install my plugin in localhost but not in my server
- WordPress plugin tables become corrupt
- Deactivate plugin on registration
- how can a plugin return an error message on activation?
- Is there a canonical way for a plugin to install a mu-plugin or drop-in?
- My activator class isn’t running the code inside
- What is the difference between $post_id and get_the_ID()?
- Where to store plugin settings fields
- How can I add columns to the post edit listing to show my custom post data?
- What’s the best method for emptying an option created with the Settings API?
- template_include (overriding default plugin templates via current theme)
- Custom frontend page for plugin without a ‘physical’ page?
- Update exisiting site to 3.5 release candidate
- Using AJAX in a plugin to submit form – REALLY confused
- Plugin Architecture/Design Pattern – is better to use a private Observer/Mediator Pattern for plugin subclasses or WP add_action?
- Post added via wp_insert_post with category doesn’t show in category listing
- How to add more than 1 user role to sub-menu pages
- How to get shortcode to work inside a foreach loop called within a shortcode?
- How to properly use a hook to create template for custom product type in a plugin such as Woocommerce? [closed]
- How to bundle a plugin with a theme, or vice versa
- WordPress Media mime type filter problem 4.0
- Using a front controller in a WordPress plugin, any suggestions?
- How do I determine if a category exists by ID?
- Use theme constants in plugin?
- Self-hosted plugin update problems
- How to avoid creating first submenu page that is same as menu page?
- How can I display an error message after post has been saved?
- Best choice of options/settings framework for plugin/theme development
- GET parameters interfere with my plugin settings
- What’s the best place to hire a freelance (contract) WordPress developer? [closed]
- How to use relative path with my plugins folders?
- Files automatically added
- Plugin Deactivate Self on Activation Errors
- How to add plugin version update option in plugin row action?
- wp_filesystem put_contents issue with owner/group
- Create custom HTML/JS app inside page
- Plugin Development for registered users
- Widget options are not updated
- Upload multiple images and insert them into custom html code
- Gutenberg table block with Bootstrap .table class
- Do blocks replace plugins in WordPress 5?
- Show dynamic list of products from custom api of another database under same host
- Hide custom post type by user roles
- Using OOP inside a Plugin – Is it allowed?
- why isn’t require_once working with my path names
- Odd map_meta_cap $args on post edit — sometimes integer, sometimes string
- How can I create a custom plugin that allows anonymous users to signup without registering?
- How to grab query string from wp-content/uploads/.*
- How to call a function using a shortcode [closed]
- How to add template colors to custom block options in WordPress Gutenberg editor sidebar?
- WP: Search and replace in DB programmatically
- Update a user profile via frontend
- Get images / media attached to a page by page ID
- How to create two custom post types when plugin is activated?
- Any way to update_post_meta with html content? It gets stripped and becomes empty
- How to get the number of pages when paginating comments?
- Add code to template dynamically
- Getting posts by taxonomy
- can members have multiple registration using the same password?
- WordPress (pagenow link) in ajaxurl change after i change plugin language
- Creating posts with links from a txt file
- Get API auth_token token to renew weekly
- Detect if requested page is PWA on server side
- Redirection from a specific page for users logged in but not with membership
- how to add security questions on wp-registration page and validate it
- Allow user to add the php code in wp_mail()
- Hiding WordPress REST endpoints from public viewing using Basic Authentication
- Plugin setting page – update_option problem
- Customize WordPress Admin Menu
- WordPress Plugin Update Process
- Rewriting URLs with a query string
- Registration form Plugin… Email confirmation
- Forcing ALL plugin Admin menus into a separate menu
- Looking for Hook that is fired after a plugin or wp upgrade is installed/updated
- How to display posts list on my plugin page?
- WordPress pre-build slider