Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mlbd/2c4e1836eca1a521c4d3fe12ab831f9a to your computer and use it in GitHub Desktop.
Save mlbd/2c4e1836eca1a521c4d3fe12ab831f9a to your computer and use it in GitHub Desktop.
/**
* Change Elementor Editor "Submit" Button Text for Non-Publish Users
*
* Replaces the "Submit" button label with "Send for Review" in the Elementor editor UI
* for users who lack the 'publish' capability. Useful for Contributor roles or
* custom workflow permissions.
*
* Add to your theme's functions.php or as a small plugin.
*
* @author OpenAI ChatGPT (2025)
* @see https://github.com/elementor/elementor/issues/20061
*/
add_action('elementor/editor/after_enqueue_scripts', function() {
?>
<script>
window.addEventListener('load', function() {
// Run only in Elementor editor context (robust body class check)
var body = document.body;
if (
!body.classList.contains('elementor-editor-active') &&
!body.classList.contains('elementor-editor-wp-page')
) return;
function updateSubmitButton() {
// Find the MUI "Submit" button (Elementor v3+)
const btns = document.querySelectorAll(
'button.MuiButton-containedPrimary.MuiButton-sizeLarge, button.MuiButton-containedPrimary.MuiButtonGroup-firstButton'
);
btns.forEach(function(btn) {
if (btn.textContent.trim() === "Submit") {
btn.textContent = "Save Changes"; // Change this text as desired
}
});
}
// Initial run
updateSubmitButton();
// Watch for UI/React changes to button (in case of state updates)
const observer = new MutationObserver(updateSubmitButton);
observer.observe(document.body, { childList: true, subtree: true });
});
</script>
<?php
});
@mlbd
Copy link
Author

mlbd commented Jul 29, 2025

Change Elementor Editor "Submit" Button Text for Non-Publish Users

This snippet customizes the "Submit" button text in the Elementor editor for users without the “publish” capability (such as Contributors or custom roles). It replaces "Submit" with "Send for Review" (or any custom text) in Elementor’s React-based UI (v3.x+). The code uses the official elementor/editor/after_enqueue_scripts hook to inject JavaScript only into the Elementor editor interface.

How to use:

Add this code to your theme’s functions.php file or in a custom plugin.

Change the replacement text in the script if needed.

This does not affect the frontend or classic WP admin pages.

Works with Elementor v3.x+ (2024 or newer).
Does not require any third-party plugins.
For more advanced targeting (user roles, workflow), enhance the logic in the PHP or JS as needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment