The easiest way would be to set the href URL to instead point to a PHP file that first sends the email you want, and then triggers a force download of the image file path that you specify.
Alternatively you could set an onclick
event to the link to execute Javascript to AJAX via /wp-admin/admin-ajax.php?action=
and then hook a function to the AJAX action in WordPress. There are many tutorials on available on how to add AJAX actions, but basically (where image_email
is the action
variable set in your AJAX call.):
add_action('wp_ajax_nopriv_image_email', 'custom_email_function'); // for logged out users
add_action('wp_ajax_image_email', 'custom_email_function'); // for logged in users
function custom_email_function() {
// send email code
}
Related Posts:
- How to get current page ID outside the loop?
- Get the content of a specific page (by ID)
- How to give paged links custom title?
- Show Default Editor on Blog Page ( Administration Panel )
- Create pages automatically if they don’t exist
- Order by menu_order and title?
- WP Page and Subdirectory with same name
- How to redirect on particular page in wordpress? [closed]
- Internal Links to Pages in PHP?
- How to inject custom url path for page ?
- Restrict acceess of a page in backend
- How to display page title+link of page created by user
- WordPress twenty eleven sidebar on Pages
- Debugging shortcode problems
- How to disable Page Attributes dropdown in wp-admin
- How to show updated edit on preview URL without clicking preview button
- The entire content of my WordPress page has disappeared
- How to redirect a page to subdomain?
- How can I have two content titles?
- Get the Page Content,without generating HTML
- How can I split long posts into pages?
- Slug is redirecting to 404
- Include content from one page to another
- Can I include Javascript/jQuery in a page?
- conditional tags- how to use with shortcodes
- List all private pages user has access rights to read
- “next page” of parent in infinite loop
- Access the same page from multiple urls (wildcard)
- How to update the counter of private pages in the dashboard?
- Using in-build Visual Composer param types in custom param types
- Google Analytics tracking code on just one page?
- Layout Builder.
- Edit custom HTML page from WP admin dashboard
- get_pages() as per custom menu order
- Pass data from one page to anothe file/page in wordpress
- Display child pages in sidebar of parent page in wordpress
- Display child pages in a parent page? [closed]
- How to use is_admin in page content?
- Adding a Calculator to a WordPress Page
- Why isn’t WordPress respecting my HTML?
- From a developer’s point of view what are the differences between pages and posts? [closed]
- Edit page shown after login in WordPress?
- invalid argument in foreach when trying to list custom post types in archive.php
- Page titles for internal classification of landing pages
- Use content from one page in another template
- How do I edit text displayed on my browser tab?
- Is it possible to change slugs’ default behaviour?
- List child pages within page template
- Page menu not showing in admin, new Page button missing in toolbar too
- Keep page hierarchy in wp_list_pages, even if on a child or grandchild
- Order by modified date working in POSTS but not PAGES
- append one page content into another
- WordPress Page doesn’t load the template selected
- on page creation few inline style properties gets removed
- Custom folder for wordpress page templates
- way to make all pages with certain tags public?
- Page not appearing under its Parent
- Can I use Pages like a Wiki
- list child-pages as normal pages?
- return page name in url
- Create multiple pages with tables from json file
- Search anything from a Child and Sub-Pages of their Parent page
- Can i use 2 page content-forum & content-forum-slug on bbpress?
- register_rest_field only for specific page
- Attaching a file to a page without adding to media library?
- Change page width in refined magazine/mag and news theme
- How do you run code on a specific page without missing the init hook?
- Groping Pages Per Department Option
- Requiring a Visitor to Enter a Password Each Time They visit a Page
- if is_page() is not working with wp_redirect
- Display meta data attribute in user profile
- Assign Parent Page – Now 404 Error
- WordPress displays widgets out of whack
- WordPress form submit to custom page template does not work
- Two different layouts for the same post
- My page title turns into a h2 tag – What to do?
- How do I locate a third party page represented as a slug in my WordPress website?
- Customise the_title in admin area
- Add pagination to search.php page
- problem with loading pages
- Content not displaying on page
- Blank white space where header was [closed]
- How do I get my page “About” to show up on my WordPress site?
- Display child pages on homepage template
- Set order acs and no paging for archive page
- Pageview all of sudden not working
- Childpage title + content on Parent Page
- Pulling posts tagged with similar title name
- Filter posts by author selected in page
- Temporary download page or restrict static download page based on how the user got to the page?
- search page different results
- List Parent page with sub pages
- Adding a filter to wp_edit_posts_query() to prevent hierarchical display of pages
- wordpress user profile page
- WordPress is picking up links that don’t exist
- Split Page Links
- Ask for template when adding a new page
- I reached halfway through a WordPress tutorial to find out I began wrong for a new comer to WP
- Can’t create new pages in wordpress
- Custom template is not showing up in templates dropdown list after re-naming it