To simplify your process and prevent redundant conditional checks just stack the two actions on top of each other.
wp_ajax_
runs for authenticated users and thus does the conditional check of is_user_logged_in()
anyway. wp_ajax_nopriv_
does the same thing, but looks for unauthenticated users.
The actions themselves run the conditions anyway, so you needn’t run it again:
function get_update_clickCount() {
//your code here
}
add_action( 'wp_ajax_get_update_clickCount', 'get_update_clickCount' );
add_action( 'wp_ajax_nopriv_get_update_clickCount', 'get_update_clickCount' );
Related Posts:
- Ajax call not working anymore
- Ajax form submission from admin panel
- How to securely add an Ajax button to a WP Admin page?
- wp_remote_get() to get AJAX url /wp-admin/admin-ajax.php
- Issue with front-end ajax, getting a 302 redirect when accessing wp-admin/admin-ajax.php
- Ajax call in wordpress not working for subscriber user in front site
- Ajax Redirect role = ‘Editor’ to their Dashboard after register
- AJAX requests broken due to HTTPS for wp-admin
- Allow AJAX call to other roles than admin
- wp-admin AJAX with Fetch API is done without user
- WP Admin AJAX Security – using POST to include a relative URL
- WordPress Ajax Not Working ( Custom Admin page)
- Why a strange discrepency between get_current_user_id() when using AJAX versus output of document.cookie?
- Pass additional parameter with async upload
- Use WP admin AJAX url to hide API key
- Preprocess submitted data
- How to check nonce lifetime value of plugins?
- Use AJAX in a WordPress Plugin to Get Data From Custom Database?
- admin-ajax.php returns 0 even when the post status code is 200 OK
- Can I use application/json content type in WordPress
- Adding user using admin ajax by a user with custom role
- wordpress admin ajax trash_comment
- WorddPress website admin part not working correctly – I think ajax/json issue
- How modify comments metabox on post edit screen in WordPress?
- Weird admin-ajax.php problem
- WordPress Get Header and Footer using in Admin Area
- get_comments() returns empty array if called through AJAX
- WordPress blocking polling request when signed into Admin
- Front-end ajax problem all users and guests getting a 302 redirect when accessing wp-admin/admin-ajax.php
- randomly get 400 error while user is logged in wp_ajax
- Blocking admin-ajax.php from outside domain
- contact form 7 form not working in admin panel
- How does the security of admin_ajax.php work?
- Allow guest to update custom post met using ajax
- AJAX Post from same domain to a wordpress page
- WordPress Ajax JSON success return no being recognized
- How to fetch meta_value and meta_key in matrix after ajax request by post_id
- Can Ajax Action [add_action(‘wp_ajax_{action_name}’, ‘{action_name}’] be hooked into wp hook
- First time doing Ajax with WP, how to do it?
- Ajax contact form returnig 0
- Strange AJAX problem (SOMETIMES works in Chrome/FF, ALWAYS works in Midori)
- Session variables lost during Ajax calls – WordPress – Sage Starter Theme
- Unexpected WordPress search results
- How to check for dependencies for a specific page and enqueue them
- wp_ajax_action, wp_ajax_nopriv_action not working
- Simulate a specific page when making AJAX calls
- Tie the sending of an ajax request to WordPress hooks
- How to use nonces for frontend AJAX voting if the page gets cached?
- Know which script/page is being called by ajax call
- Ajax live search, “No products found” when the title contains apostrophes and quotations
- Get Page Type (Category/Tag) Using AJAX
- AJAX: admin-ajax.php is adding extra content to my script’s response – how to exclude header, footer, etc.?
- Trying to send AJAX data to WordPress hook
- Add Ajax loaded posts to existing posts
- wp_enqueue_media problem
- WordPress page content only in fancybox except direct click
- Ajax takes 10x as long as it should/could
- Ajax Form data is not posted back to the get_results()
- AJAX Call in Plugin Returns More than JSON
- Loads posts of different year via AJAX call
- Using AJAX for dynamic settings pages
- Ajax take too long to return code
- While doing ajax, WordPress returning internal server error 500 and stating that my theme functions are undefined
- Usage of wp_send_json_success and wp_redirect at the same time
- Ajax return 0 in plugin – ajax only used in wp-admin
- Speeding up admin-ajax.php
- admin ajax is not working for non logged in users
- Data from ajax not updating post meta
- How to load post_meta for custom post type via Ajax
- Manually cache a special, non-WP-but-using-WP page (e.g. Ajax results) with W3TC
- Is it a good idea to init ajax functions only while ‘DOING_AJAX’
- Change search to outpout category name instead of Post type name
- ‘Dehighlighting’ navigation once clicked
- problem when adding wp_editor with ajax [duplicate]
- Get wp-load.php PATH with wp_localize_script and JavaScript for plugin
- Can’t update WP Editor after Ajax
- Can I make an ajax response cross-domain?
- SHORTINIT and sessions
- How to use AJAX to check if user is still logged-in?
- Update user meta using Ajax on front end?
- Remove dashboard access but allow ajax file upload
- retrieving page content per AJAX [duplicate]
- Ajax navigation and scripts loaded only on certain pages
- fail to load /wp-admin/admin-ajax.php locally
- Load more posts with Ajax and masonry
- Ajax Form seems to post, but does not return
- Ajax request to admin-ajax.php and window.location.href
- Objects and get_post_meta() gives me 1 string for latitude and longitude
- wp_localize_script not create variable in head section
- Closing ajax function file with die() causes error and empty page
- BBPress AJAX problem
- How to load wordpress sidebar using AJAX [duplicate]
- Why can wordpress not find the actions I add in my constructor?
- delete attachment for one post without deleting actual attachment post
- Caching for logged in user and Ajax update
- update_user_meta updates to a wrong ID
- Memberpress isn’t cooperating with WooCommerce
- Ajax object comes back empty
- where does my function output from load-* go?
- Posting to loop.php file