You can use get_current_user_id()
to get the ID of the current user, and in your case, you can do so to print the user ID in the JavaScript Li.re()
call:
<script type="text/javascript">
Li.re( 'ab12','<?php echo get_current_user_id(); ?>' );
</script>
And yes, you can include the user ID as part of a shortcode: (note that I omitted the href
parameter for simplicity)
<?php echo do_shortcode( '[mycred_link subid1="' . get_current_user_id() . '"][/mycred_link]' ); ?>
PS: Your shortcode was missing the closing ]
tag, so I added it above. All shortcode parameter values should also be wrapped in single/double quotes.
Related Posts:
- Is it possible to reuse wp.media.editor Modal for dialogs other than media
- How to implement color picker from wordpress in my plugin?
- Add async script
- How to provide translations for a WordPress TinyMCE plugin?
- How-to implement admin Ajax inside an admin WP_List_Table?
- Include third party Javascript library which is not included in WordPress
- Hook the Keydown Event in the TinyMCE Post Editor
- WordPress REST API call generates nonce twice on every call
- How to Add a .js file Only in one specific Page Dynamically to Head
- How to trap “Publish” button to check for meta box validation?
- Pass javascript result to shortcode executer function
- The changes I make to an external JS file of my WP plugin are only applied after I clear my browser’s cache
- `wp_set_script_translations` with `wp.i18n` does not return translated strings in simple plugin
- Custom user profile, registration, login page with theme
- Use js script from one plugin in another plugin
- creating elements/innerblocks via rangecontrol
- Making a custom widget that includes a tinymce and works in Site Origin Page Builder
- How to add quick edit and bulk edit fields to users admin section
- Looking for callback function after Gutenberg is rendered?
- What’s the better way to add an inline script?
- Can’t get JS code to work with shortcode
- How do I add a javascript file to all admin pages via a plugin?
- WordPress admin deleted user details not removed in database. How to delete WordPress Users from Database
- Gutenberg – What is the best way to save/update post meta?
- Prevent Javascript Facebook SDK Conflicts in plugin
- how to include javascript file and css file in wordpress
- Mixing Regular Javascript With jQuery in a Plugin
- How to run a external JavaScript file on wp-admin if admin, and other if normal user?
- Why is my javascript not invoked in my hooks except wp_head?
- Where to call wp_enqueue_script in a plugin with custom template?
- Subscribe to author?
- How to filter users list on user_status field with get_users()
- Is there an event or an other method that tells me the preview is loaded?
- WordPress Plugin with a shortcode that dynamically generates javascript. Can I use add_action without wrapping the javascript in a function?
- How to prevent UNDO on guternberg block editor
- Do I have to worry about useState causing a re-render?
- Creating a custom Gutenberg block with columns
- “import declarations may only appear at top level of a module” when importing WooCommerce API node module
- wp.template() returns tags in Ajax response
- My WordPress plugin cannot load my JavaScript file
- add javascript files only when plugin is called?
- Display list of uploaded images, filtered by user under a specific user group
- Inserting code to HTML view from a pop up initiated from visual view
- Plugin – Make sure jquery is loaded in my settings page plus my JS file
- How can I avoid conflicts between plugin and theme?
- How to control an elements classes from multiple Gutenberg sidebar controls?
- How should I go about registering JavaScript that isn’t a file? [duplicate]
- What action hook can I use to add a JavaScript to a page post using a theme template that is not including get_header() nor get_footer()?
- How to build a fool proof AdSense revenue sharing model?
- should i be checking for jquery before enqueing it in a plugin
- How do I have now a duplicated user entry if this is not allowed (and I cannot replicate it)?
- How to allow only two (or more) users access to a plugin
- get author of published post
- Translate javascript with WordPress built-in localization API for static strings
- How to get custom post_author?
- Need help about understand api, wp, $ syntax in WordPress plugin script
- Insert Into Post Not Working For Audio File Using jQuery
- Developing the save function in Gutenberg blocks
- Adding another field to user table
- How to insert HTML/CSS/JS into my iframe plugin?
- Is there a WordPress plugin to design WebGL? [closed]
- How to relate the Category to user?
- How to write a shopping queue line plugin with a queue button?
- wp.media libary pdf type
- wp.media gallery collection sometimes undefined
- Getting incorrect filepath inside custom block front-end output using @wordpress/create-block tutorial
- Trigger function on Remove block or add new block in Gutenberg JavaScript
- Multiple TinyMCE on button click is initialized and appended but why only last one is writeable?
- Rerender core Templates with with ToggleControl but it doesnt recognize block type
- HTMLCollection not counting right in editor? / for loop not working on elements in DOM
- converting a node.js project into a wp plugin
- Is “document loaded” different on admin side than public side?
- Why User_login key doesn’t work with wp_update_user()
- How to use setAttributes outside of the edit function return
- why is apiFetch throwing Unhandled Promise Rejection: TypeError: Object is not a function
- How to grab data after wp user search is complete
- Reading plugin settings in esnext wordpress block
- Dynamically modify content added to table via javascript
- Load script on frontend from widget plugin
- WordPress with React: Saving and Using Data Collected with fetch
- Javascript scroll eventHandler only working when I’m logged in in WordPress
- Replace the WordPress Media Library Uploader
- Using JavaScript in WordPress page to call for server data using AJAX
- Pass javascript result to shortcode executer function
- Add a Script button in W3 Total Cache plugin not working due to conflicting jQuery version
- Add language localisation to javascript alert?
- User Registration Moderate
- Uncaught ReferenceError: kpoejy is not defined
- How to retrieve custom profile fields associated with different users
- Remove from a div by class name from post page if post author role is not administrator
- first_name property missing inside register_user action hook
- On one of my sites a file is shown as 404 but the file IS there
- How do I use (or mimic) document.getElementById() on a page loaded from WordPress database?
- user can login from single account detail from multiple locations(computer) at the same time [closed]
- How can i add insertion point between inner blocks in my custom block like core blocks
- How do I access the contents of WordPress Classic editor in admin area with JavaScript?
- How to get the value entered in the input field in wordpres
- How react js and other Javascript Technologies works on WordPress plugin?
- Trigger a JavaScript function based on the data fetched from Woo commerce hook
- Trouble Importing whatsapp-web.js in a WordPress Plugin Development