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
- WordPress getting data from external API
- how to send csv file to other server using wp_remote_post?
- How do I return XML to an API post request
- Default table collation on plugin activation?
- How to implement color picker from wordpress in my plugin?
- Nonces can be reused multiple times? Bug / Security issue?
- How to auto-upgrade my plugin?
- Category listing with thumbnail and description on home page
- How to Add a .js file Only in one specific Page Dynamically to Head
- Missing “category_children” option when dynamically creating categories via a plugin
- Developing a plug-in to charge for
- What is the Difference between directly call a function and call a function using add_action?
- What is better way to use Bootstrap inside admin panel?
- Updating my plugin without releasing a new version
- 404 errors after plugin options update and category base change
- How to determine, from plugin script, if active theme has The Post Title
- Widget Admin – Form Submit Event?
- add_filter : Passing an array instead of the callback function?
- Using wp_parse_args to set up Plugin Default Settings
- how to add Jquery script to one page?
- how do you prevent showing a particular category on the admin dashboard for specific user roles?
- get_posts() not working when accessing with a custom user role
- Do I have to worry about useState causing a re-render?
- Plugin sub-menu pages recommended structure and links
- template_redirect or admin-ajax.php?
- mysql_real_escape_string() vs. esc_sql() in WordPress
- jQuery does not enqueue for my purpose… (before an inline script in the footer)
- how to get all the child category name in a specified category name?
- Can I add custom css to an mu-plugin?
- Change WooCommerce Email Header using custom plugin
- How to get the current page Title and Page URL in footer.php
- insert query on a custom table using ajax with jQuery plugin Jeditable
- How to add search form in main page body?
- WordPress Rest API with rest_do_request, possible race condition?
- Need help about understand api, wp, $ syntax in WordPress plugin script
- Get section of input passed to the sanitize_callback
- Adding tables to dashboard pages programmatically?
- Dynamically modify content added to table via javascript
- How to prevent wp_insert_post from creating a new post every second?
- Download stopped working in 4.7.4
- $wpdb Mysql trigger problem
- WordPress postboxes On Tabbed Views and Hiding Registered Pages
- grouping my widgets wordpress
- Yet another wp_insert_post infinite loop. What is wrong?
- Initialize class inside plugin
- “Print to printer” functionality in a plugin
- Which subset of html does WordPress support?
- How to set init for maximum script execution, memory limit and max files upload in wordpress