Jump to the post that solved this thread.
Solved: 9 Months, 3 Weeks ago Cookie Law - Redirect to original post
#1
Solved: 9 Months, 3 Weeks ago Question 
Hi,

hope I'm in the right section.

Plugin: Cookie Law

When you press "Allow cookies" or "Disallow cookies" in the Opt In/Out Display Method, the plugin redirects the guest to the forum index.

I don't know if there's a way to redirect them to the original post (or thread) they arrive from Google (for example).

Note 1: my country makes us to use the Opt In/Out Display Method.
Note 2: not all visitors arrive to the index page, as I said if they search something they'll get in the post first, and if they allow the cookies they will loose the post where they were to go to the index of the forum.

Thanks for your time.
I don't answer questions about localhost forums or forums without URL, I'm not a seer.  Cool
Reply
#2
Solved: 9 Months, 3 Weeks ago
We can try to use the sam code that MyBB uses for quick log-in. Open the plugin file, find:
redirect('index.php', $lang->cookielaw_redirect);

Replace with:
redirect((string)$mybb->get_input('url') ? (string)$mybb->get_input('url') : 'index.php', $lang->cookielaw_redirect);

Edit both the cookielaw_info and cookielaw_header templates. Find the following code within:
<form action="{$mybb->settings['bburl']}/misc.php?action=cookielaw_change" method="post" ="cookielaw_form">

Replace with:
<script type="text/javascript">
 $("#cookielaw_form input[name='url']").val($(location).attr('href'));
</script>
<form action="{$mybb->settings['bburl']}/misc.php?action=cookielaw_change" method="post" id="cookielaw_form">
<input name="url" type="hidden" value="">

I'm unsure if the <script> tag needs to be below the <form> one, try moving it if it doesn't.

Report us back if it worked.
Reply
#3
Solved: 9 Months, 3 Weeks ago
Hi,

thanks Omar G. for your time, but it didn't work, keeps redirecting to index.php, like the url  input is empty.

Tested with the script above and below.

Ok, fixed, and now it works.

Plugin with the line changed as you said.

cookielaw_info and cookielaw_header templates:
<form action="{$mybb->settings['bburl']}/misc.php?action=cookielaw_change" method="post" id="cookielaw_form">
<script type="text/javascript">
  document.write("<input name=\"url\" type=\"hidden\" value=\""+document.URL);
  document.write("\" />");
</script>

Thanks again for show me the right path to change it, I spent 2 days before asking and no advance.

Muchas gracias Omar G.
I don't answer questions about localhost forums or forums without URL, I'm not a seer.  Cool
Reply
#4
Solved: 9 Months, 3 Weeks ago
No problem. However, I meant to move it below the end </form> tag.
Reply
#5
Solved: 9 Months, 3 Weeks ago
I have attached the hook file for those not wanting to edit the plugin file and uses the Hooks plugin.


Attached Files
.xml   cookielawredirect.xml (Size: 1.13 KB / Downloads: 24)
Reply
Jump to the post that solved this thread.


Forum Jump:


Users browsing this thread: 1 Guest(s)