Just use wp_localize_script()
and is_user_logged_in()
.
wp_localize_script(
'my-ajax-request',
'MyAjax',
array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'logged_in' => is_user_logged_in()
)
);
Related Posts:
- Javascript split regex question
- What is a good regular expression to match a URL? [duplicate]
- What is a good regular expression to match a URL? [duplicate]
- Is there a difference between /\s/g and /\s+/g?
- RegEx Ignore Case
- JavaScript replace/regex
- Regex for password must contain at least eight characters, at least one number and both lower and uppercase letters and special characters
- Escaping Discord subset of markdown
- How to test valid UUID/GUID?
- Regular expression : match either of two conditions?
- RegExp in TypeScript
- Converting any string into camel case
- I want to remove double quotes from a String
- Regular expression for removing whitespaces
- Javascript Regular Expression Remove Spaces
- How can I extract a number from a string in JavaScript?
- Remove not alphanumeric characters from string
- Extract hostname name from string
- Difference between ?:, ?! and ?=
- Remove all special characters with RegExp
- How do you use a variable in a regular expression?
- How to count string occurrence in string?
- Regular Expression to reformat a US phone number in Javascript
- Jquery Value match Regex
- RegEx: How can I match all numbers greater than 49?
- Regular expression to validate US phone numbers?
- javascript includes() case insensitive
- RegEx for Javascript to allow only alphanumeric
- “Password Strength Unknown” Registration Issue
- how to refresh page after user logout with ‘wp_logout_url’?
- What does “javascript:void(0)” mean?
- For-each over an array in JavaScript
- require is not defined? Node.js
- Encode URL in JavaScript?
- JavaScript null check
- JavaScript “Uncaught TypeError: object is not a function” associativity question
- Module not found can’t resolve
- How can I get file extensions with JavaScript?
- How to detect Safari, Chrome, IE, Firefox and Opera browser?
- What does on() in JavaScript do?
- AngularJS : Factory and Service?
- What’s the difference between console.dir and console.log?
- Use images like checkboxes
- Uncaught TypeError: Cannot read property ‘msie’ of undefined
- How to hide a div with jQuery?v
- How do I pass variables and data from PHP to JavaScript?
- How do I set/unset a cookie with jQuery?
- Calling onclick on a radiobutton list using javascript
- How to properly export an ES6 class in Node 4?
- Uncaught Typeerror: cannot read property ‘innerHTML’ of null
- Sorting HTML table with JavaScript
- Relation between CommonJS, AMD and RequireJS?
- how to download file in react js
- TypeError: $(…).DataTable is not a function
- Trying to use fetch and pass in mode: no-cors
- Moment.js transform to date object
- jQuery explode string like PHP
- Call Javascript function from URL/address bar
- Anagrams finder in javascript
- Validate date in dd/mm/yyyy format using JQuery Validate
- How to subtract days from a plain Date?
- Stopping a JavaScript function when a certain condition is met
- Showing an image from an array of images – Javascript
- Javascript isnull
- What’s the best way to reload / refresh an iframe?
- How do I check if a cookie exists?
- Get querystring from URL using jQuery [duplicate]
- Check if string contains only digits
- JS: iterating over result of getElementsByClassName using Array.forEach
- jQuery checkbox change and click event
- Error: listen EACCES 0.0.0.0:80 OSx Node.js
- jQuery selectors on custom data attributes using HTML5
- How to check if a value is not null and not empty string in JS
- How do I refresh a DIV content?
- TypeError: abc.getAttribute is not a function
- window.location() not working, not opening page
- How to clear the canvas for redrawing
- What’s a Good Javascript Time Picker?
- JavaScript event window.onload not triggered
- Default text on input
- JSX not allowed in files with extension ‘ .js’ with eslint-config-airbnb
- Pass custom fields values to Google Maps
- How can a Firebase user registration and login be integrated into a WordPress site?
- WP Customizer set a value via javascript (to create presets)
- wp_enqueue_script adds only the first script
- Add javascript to a woocommerce page template
- Dynamically insert values in a WordPress SelectControl Options field
- Vimeo froogaloop
- What javascript libs & frameworks are integrated in WordPress vanilla?
- InnerBlocks restricting does not work on nested blocks
- Uppload image from another source wp.media
- How to open the add media dialogue it in a certain state / tab?
- Putting custom html/js page into Elementor as it’s own block
- Drag-to-Scroll Landingpage
- Easiest way to find JS conflicts
- Nothing in dashboard that uses javascript works
- XMLHttpRequest of admin data to public
- How to execute WP shortcode in a javascript string “”
- PHP or JS for header image rotator?
- Replacing & in JS code on pages