The code in the file itself can be executed multiple times. If you want to do something when the plugin is activated use register_activation_hook and wrap your email sending codes in it.
function my_plugin_activation() {
//Setting up the credential
...
}
register_activation_hook( __FILE__, 'my_plugin_activation' );
Related Posts:
- Difference Between Filter and Action Hooks?
- How can you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?
- How to create an API for my plugin?
- How to store username and password to API in wordpress option DB?
- Is there a limit on making calls to WordPress.org API’s?
- Using filters and actions for plugin API?
- WordPress and multithreading
- permalinks with get variables
- Build dynamic page from cURL (HTML page) response with plugin
- How to override a function call in functions.php?
- wp_enqueue_style built in styles
- Should I ask my Twitter plugin users to create their own Twitter App and API Keys to use my plugin?
- Does WordPress’s HTTP API use any caching?
- Example Dashboard Widget, Cancel not working
- Amending REST API function without deactivate/activate plugin every time changes is made
- Why does wp_remote_post returns an empty body response on certain endpoints?
- Adding custom end points, No error line
- Sending post request with wp_remote_post not working correctly
- woocommerce_checkout_order_processed hook executing function twice
- What to hook into to check a value before a post is published?
- Encoding Method for URLs?
- Google credentials and redirect URI for Google OAuth2 in a WordPress plugin, questions
- Pass CF7 form data to plugin
- Best way to ping for the API changes in the wordpress?
- Plugin architecture to pull from API & create dynamic content on WP site?
- Lead form that submits to 2 external APIs
- Widget internal hooks and functions
- Allow REST API Endpoint to specific user and hide from public
- Custom Endpoint – Does it possible to use PUT method with WP API Rest?
- Get API auth_token token to renew weekly
- How to query a nested field in wordpress api using _fields param
- call funcution when clicking submit
- Adding Amchart Interface to WordPress API
- How do I make secure API calls from my WordPress plugin?
- Generate Static Page to Show Search Results/Detail for API
- Using AJAX to submit and return data inside the WordPress Plugin Boiler Plate framework
- Hiding WordPress REST endpoints from public viewing using Basic Authentication
- add pagination to wp_remote_get
- Multisite and the JSON REST API: How to?
- How do WordPress plugins work with oAuth2 APIs?
- API WordPress is Limited? Return False
- Tie specific functions to options-update for limiting API requests
- Do you see any problems (mainly security-related) with how I’ve used wp_ajax_* actions?
- Is there a way to tell if a shorcode’s handler is being run before or after the content formatting filter?
- Can a plugin differentiate syndication feeds from actual site views?
- Developing a plugin, ran it through P3 Profiler, shows up slow, but I don’t know why
- add_rewrite_rule not working
- How do I query posts and have their related taxonomies returned in the results?
- modify buddpress adminbar only in admin pages
- How to update WordPress Plugins in your own maintance application?
- Programmatically creating posts based on external JSON feed (asynchronously)
- External api call using wordpress
- How are bulk actions handled in custom list table classes?
- Creating Settings Page with dropdowns for Plugin
- Empty POST data on server on AJAX request using Angular $http
- Custom Nav Menu items default to ‘menu-item-type’ => ‘custom’. How to make a “page” menu item?
- Actions or filters fired when data is saved in a custom table
- Implementing namespaces in plugin template
- How to get current page name in my wordpress plugin
- Conditional add_filter?
- Use register_taxonomy() in register_activation_hook()
- Calling apply_filters on non-documented hooks
- Commit changes to WordPress Plugin SVN with TortoiseSVN
- add_shortcode is not working [duplicate]
- How to get the post content after WordPress post processing?
- Global State During an Admin Post
- Display custom fields in frontside user profile
- Strange issue saving custom field data for a WooCommerce order
- Selectively update themes in WordPress multisite
- jQuery instantly executes (a button click and css change) on load
- Meta box on options page save form problem
- How to make my shortcode load scripts and styles, from within the plugin?
- Class cannot be found, but it’s available in the file, I get: Fatal Error: Uncaught Error: Class ‘Blocks\Base\Activation’ not found
- how to change image of jquery slider plugin
- Sending an SMS on new order placed – WooCommerce
- Where to use nonce
- Gravity Forms Anchor only on Front Page?
- Multiple page plugin settings
- how to get the top 10 popular blogs
- Set page to draft on plugin deactivation
- Can one plugin activate another plugin via script?
- script seem not load with use wp_enqueue_script
- Do I lose translations when I change my Text domain for my plugin on wp.org?
- Override woocommerce loop-start.php from theme using plugin?
- Get value of custom checkbox from Gutenberg sidebar in plugin
- jQuery dependent script ignores $in_footer bool and doesn’t work in header
- Hiding class namespace from plugin’s extensions
- Relational / Associate tables using native WordPress functionality
- Pull commentdata for pre_comment_on_post from comment_post_ID
- Woo-commerce: Adding additional page sections using a child theme
- How to get html tag ids from template?
- PHP Fatal error when using plugin_basename
- How to Rewrite WordPress URL for a Plugin
- How to Prove Ownership of plugin [closed]
- Reading the inside of
- WordPress, GIT, Renamed Plugin Dir + files – Working Code now Broken [closed]
- get_term_by() returning null on plugin
- Fetch Custom Woocomerce filed data and check the data avialble in Wp-user table as nicname or username using function.php
- How to get locale within WP REST Request?
- How to add extra EXIF data when images are uploaded?