Below, you’ll find a detailed guide on how to add the RomethemeForm For Elementor Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the RomethemeForm For Elementor Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the RomethemeForm For Elementor Plugin and the shortcodes it provides:
"RomethemeForm For Elementor is a robust WordPress plugin designed to simplify form creation on Elementor. Perfect for users who aim for easy, efficient, and customizable form building."
- [rform]
RomethemeForm For Elementor [rform] Shortcode
The Romethemeform shortcode is designed to generate a customizable form based on a specified form ID. The form includes a login requirement message and a success message, both of which can be tailored. The form is disabled for non-logged in users if the form is restricted.
Shortcode: [rform]
Parameters
Here is a list of all possible rform shortcode parameters and attributes:
form_id
– The ID of the specific form you want to display.
Examples and Usage
Basic example – Display a form using the ‘rform’ shortcode by referencing the form ID.
[rform form_id=1 /]
Advanced examples
Display a form with a specific ID. If the form with that ID is not found, the shortcode will not output anything.
[rform form_id=2 /]
Display a form with a specific ID and also restrict the form to logged-in users only. If the form with that ID is not found, or if the user is not logged in, the shortcode will not output anything.
[rform form_id=3 rtform_form_restricted=true /]
Display a form with a specific ID and also set a custom success message. If the form with that ID is not found, the shortcode will not output anything, but if the form is successfully submitted, the custom success message will be displayed.
[rform form_id=4 rtform_form_success_message="Your form has been successfully submitted!" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [rform]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('rform', [$this, 'rform_shortcode']);
Shortcode PHP function:
function rform_shortcode($atts)
{
$form_id = shortcode_atts(array(
'form_id' => ''
), $atts);
$restricted = get_post_meta($form_id['form_id'], 'rtform_form_restricted', true);
$success_msg = get_post_meta($form_id['form_id'], 'rtform_form_success_message', true);
ob_start();
if ('' == $form_id['form_id']) {
?> <h6>Please Select Form.</h6>
<?php
} else {
?>
<form id="rform" data-form="<?php echo esc_attr($form_id['form_id']) ?>">
<div class="require-login msg">
<div class="require-msg-body">
<svg xmlns="http://www.w3.org/2000/svg" width="35" height="35" fill="#FF0000" class="bi bi-exclamation-circle-fill" viewBox="0 0 16 16">
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM8 4a.905.905 0 0 0-.9.995l.35 3.507a.552.552 0 0 0 1.1 0l.35-3.507A.905.905 0 0 0 8 4zm.002 6a1 1 0 1 0 0 2 1 1 0 0 0 0-2z" />
</svg>
<div style="width: 100% ;">
<h5>Required Login</h5>
Please Login for Submit Form.
</div>
<div>
<a type="button" class="close-msg">Close</a>
</div>
</div>
</div>
<div class="success-submit msg">
<div class="success-body">
<svg xmlns="http://www.w3.org/2000/svg" width="35" height="35" fill="#4CAF50" class="bi bi-check-circle-fill" viewBox="0 0 16 16">
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z" />
</svg>
<div style="width: 100%;">
<h5>Success</h5>
<?php echo esc_html($success_msg); ?>
</div>
<div>
<a type="button" class="close-msg">Close</a>
</div>
</div>
</div>
<?php echo \Elementor\Plugin::$instance->frontend->get_builder_content_for_display($form_id['form_id'], true); ?>
</form>
<?php
if ($restricted == true) {
if (!is_user_logged_in()) {
?>
<script>
jQuery(document).ready(function($) {
$('#rform').addClass('rform-dsb');
});
</script>
<?php
}
}
}
return ob_get_clean();
}
Code file location:
romethemeform/romethemeform/modules/form/form.php
Conclusion
Now that you’ve learned how to embed the RomethemeForm For Elementor Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply