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:
- 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?
- Is it possible to reuse wp.media.editor Modal for dialogs other than media
- How to include jQuery and JavaScript files correctly?
- How to implement color picker from wordpress in my plugin?
- How can I run AJAX on a button click event?
- Add async script
- How to check username/password without signing in the user
- How to provide translations for a WordPress TinyMCE plugin?
- Add Custom User Capabilities Before or After the Custom User Role has Been Added?
- Can I use the wp media uploader for my own plugin?
- How-to implement admin Ajax inside an admin WP_List_Table?
- API to trigger prompt on leaving page
- Customizing the 3.5 “Add Media” popup (Backbone.js)
- Test to see if jQuery or Prototype is queued by another plugin?
- Include third party Javascript library which is not included in WordPress
- jQuery in header or footer
- 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
- lodash dependency in a Gutenberg plugin
- wp_localize_script $handle
- How to prevent loading of all plugin’s resources?
- 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
- How to use WP default post list tables in a plugin?
- Use js script from one plugin in another plugin
- How do I only load js on the post-new.php and post.php pages in admin?
- 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?
- Generating User(s) with Settings API
- Gutenberg: useDispatch is not a function – @wordpress/data included
- WordPress admin deleted user details not removed in database. How to delete WordPress Users from Database
- Make a list with header and subtext in Gutenberg blocks
- Gutenberg – What is the best way to save/update post meta?
- Prevent Javascript Facebook SDK Conflicts in plugin
- How to Load Plugin JS in theme’s footer section
- how to include javascript file and css file in wordpress
- Function Get User Object By Username?
- Mixing Regular Javascript With jQuery in a Plugin
- Check if someone is editing a post (this content is currently locked)
- 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?
- Modify users.php page to create page/post on button clicked
- 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()
- Frontend language per user
- 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?
- Display custom fields in frontside user profile
- 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
- Gutenberg: import dependency or assign from global variable?
- My WordPress plugin cannot load my JavaScript file
- javascript datatables in a plugin
- add javascript files only when plugin is called?
- global $current_user not current user
- Display list of uploaded images, filtered by user under a specific user group
- Remove from a div by class name from post page if post author role is not administrator
- Upgrade routine: Interaction with user confirmation
- Multiple Users Logged In Causing Incorrect Account Returned
- 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]
- Create Unique and Customized User ID for Website Members in WordPress
- 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
- How can create a custom plugin to call my webapi after any registration or membership plugin functionality
- Trouble Importing whatsapp-web.js in a WordPress Plugin Development
- Insert meta-description into Yoast-SEO input-field via JavaScript
- Reinitiate Gutenburg’s blocks using javascript
- how to add contact form 7 shortcode in javascript variable
- Insert text programmatically in WordPress Gutenberg Editor
- Javascript function defined in view.js not reachable from save.js
- How to move custom gutenberg block controls from settings to styles tab?
- How to use useSelect to retrieve the currently default fontFamily?
- Event when Modal is opened/visible
- How to apply a javascript code on certain parts of elementor made pages?
- Cannot call a class as a function in block plugin react component
- Extend backbone for add new custom Rest Api
- useBlockProps() nests wrapper with class name inside block wrapper in the editor
- Gutenberg move post/page title to Editor sidebar document panel
- configure additonal build files in the @wordpress/create-block
- Is It Possible to Use the Block Editor’s Notification Feature to Send Another Notification After the Post Is Saved?
- WordPress Plugin, Elementor and the ReferenceError nightmare