I am trying to make a plugin that allows users to add a shortcode to their website. The problem that I am facing is that once the shortcode is placed in a page the shortcode is being run on both the page editor and on the front end, where I want it to only run on the front end.
I followed this guide on how to make a shortcode. I searched around a bit on the web and saw where someone suggested adding the function ob_start();
but it did not seem to help. I have looked at other guides and no one seems to cover this issue. What am I doing wrong?
Code:
add_shortcode('sss-redeem', 'Redeem');
function Redeem(){
ob_start();
$IsAdmin = is_super_admin(get_current_user_id());
?>
<form>
<center>
<?php
if($IsAdmin){
?>
<input type="checkbox" name="overwrite" value="true">Overwrite?<br>
<?php
}
?>
<strong><h2>Order ID</h2></strong> <input type="text" maxlength="4" name="oid"/><br>
<input type="text" name="pgs" value="a5b6n66f34ka1n1d" style="display: none;" />
<button type="submit">Submit</button>
</form>
</center>
<?php
}
NOTE: I am new to developing WordPress plugins. In fact, this plugin here is my first attempt at making a plugin.
return ob_get_clean();
to reply toob_start();