MyBB Community Forums

Full Version: Plugin Dev, Form Page Consistent Loading Until Submit
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Screen Recording: https://i.gyazo.com/932e13099879fb8499a7...ce990e.mp4 

Issue:
Cookie is working on submit! It does set the cookie.

However, when the cookie is not set and the page displays the "must consent"/"verify age", the website continues to load and load and load until you click the submit button. I'm not sure why? Any help to fix this would be awesome!

Plugin Function Code:
removed

Template:
<html>
	<head>
		<title>{$mybb->settings['bbname']} - Content Restricted &ndash; {$agerequired}+</title>
		{$headerinclude}
	</head>
	<body>
		{$header}
		<form action="misc.php" method="post">
			<table width="100%" border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
				<tr>
					<th class="thead">Content Restricted &ndash; {$agerequired}+</th>
				</tr>
				<tr>
					<td class="trow1">
						{$custommessage}
						<p>The content you are about to view may contain material that is not suitable for those under {$agerequired} years of age. Due to this, age confirmation is necessary for access to this website.</p>
						<div class="error" style="text-align: center; font-weight: bold;">By submitting this form you are certifying that you are of required, and legal, age to view content that may be of adult or mature nature, and may be explicit and uncensored.</div>
					</td>
				</tr>
				<tr>
					<td class="tfoot" style="text-align: right;">
							<input type="hidden" name="action" value="contentrestricted" />
							<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
							<input type="submit" class="button" name="submit" value="I Am {$agerequired}+" />
					</td>
				</tr>
			</table>
		</form>
		{$footer}
	</body>
</html>
It's probably erroring somewhere, this isn't valid PHP:

if (!contentrestricted)

This will be treated as a constant bu it hasn't been defined, you'd need to change it to $contentrestricted to be a variable, but that hasn't been defined either.
(2022-02-04, 11:50 AM)Matt Wrote: [ -> ]It's probably erroring somewhere, this isn't valid PHP:

if (!contentrestricted)

This will be treated as a constant bu it hasn't been defined, you'd need to change it to $contentrestricted to be a variable, but that hasn't been defined either.

What about this? Since I'm not actually gathering anything other than a "submit" input.
				if($mybb->input['submit']) {
					my_setcookie("contentrestricted", true, 60*24*60*60, true);
				} else {
					my_setcookie("contentrestricted", false, 60*24*60*60, true);
				}
				redirect('index.php');

Only thing is it still constantly loads.
Can you post the URL? I tried to see it from the screencast but got a different page.
(2022-02-04, 06:56 PM)Matt Wrote: [ -> ]Can you post the URL? I tried to see it from the screencast but got a different page.

Let me send you some login credentials. I use that MyBB copy for customer stuff when I build themes and what not.

I will send through PM.


Also quick update, I was able to get the page loading to stop by adding an exit; clause after the output_page($page) portion, thanks to a youtube video lol.