I'm using WordPress with the plugin bbPress.
So far, so good.
The only thing I'm stuck at, is the fact that for certains functions to appear (like Approve Reply, Close Topic etc.) I need to refresh the page, otherwise the buttons won't appear.
How can I implement a sort of a function in order to refresh the current page just after I clicked on it?
So that basically when I enter this page, it gets automatically refreshed (and so the buttons will appear).
Thank you!
You can use header function this way:
header('Location:'.$_SERVER['REQUEST_URI']);
Related
I'm working on a site (reworking is probably a better word as I did not build it originally) and am encountering the following weird scenario:
Users go to a page which shows a list of current events. This is called "whats-on".
I have added a link to this page which takes users to a full event calendar for the month in a typical calendar format. This page is called "event-calendar". Once on the page they can also select which month they want to see and what type of events they are interested in.
Users can click on an event listed in any date to navigate to a page with the event details. (page is event-details with a query that pulls the relevant event.) I have added a back button to the page under the event listing which will return them to the calendar showing the month and search results they just looked at. No issues there - I am using PHP $_SERVER['HTTP_REFERER'] and that works perfectly.
Here is the issue - if I just did a back() or history.go(-1) link on that button, it takes the user all the way back to "whats-on". The same thing happens when you click the browser back button. It just skips over "event-calendar" entirely.
This apparently happens on the site under other scenarios such as business listings and searches.
Obviously I do not want that behavior - I want the back button to go to the previously viewed page like it should!!
I cannot think of anything in the code that would cause this, but the original site developers included a whole bunch of JQuery packages such as jQuery UI, and I'm wondering if something could be interfering with the default back button behavior. Is that even possible??
I guess what I want to know is there is any JQuery code that would change the behavior of the back button so I could hunt it down and kill it!!
Just looking for ideas as to where to start looking.
Apparently the only way I can get it to work is to manipulate the browser history using
history.pushState({}, '', 'event-calendar?<plus whatever query was used to pull the data>');
on the calendar page itself.
This seems to work but what a stupid workaround. Wish I could find the original problem.
I have a strange problem with IE. I have a sequence of forms on my website, and there is a built in navigation system to go to the next and previous pages. The pages submit to themselves, and then use Header(Location: ... ) to proceed to the next page.
The problem is that when I use the built in back button (standard tags) to go to the previous page, the input tags get populated with the old values, but when I refresh the page the values are correct. Similarly, when I use the browser back button the values appear correctly.
Sorry if this is a repost, does anyone know how to solve this problem?
Thanks!
I think it's an issue with IE caching the previous pages; if you can amend the server configuration so that it's passing the No-cache request to the browser, it should fix it.
I'm working on wordpress plugin, which handles shopping cart. I have two pages, checkout and thank you page. Items to cart are added by link like that https://mysite.com/checkout/?action=add&subscription=23 . I'm using Session for adding items to the cart on checkout page.
Suppose if I add three items added:
https://mysite.com/checkout/?action=add&subscription=1
https://mysite.com/checkout/?action=add&subscription=2
https://mysite.com/checkout/?action=add&subscription=3 (Last link in browser addressbar)
When user checkout on checkout page then user is redirected to thank you page. I have problem with browser back button, If user press back button on thank you, he is redirected again to checkout page with last item again added (https://mysite/checkout/?action=add&subscription=3 ) since this was the last link in browser address bar.
How can i prevent browser to add last item again on user back button press on thank you page?
Is there any way in PHP to detect if request is coming from browser back button? I think, there can be way to handle it using session?
Please guide me if there is any other suitable way to accomplish this? Thanks
The best way to handle that is to use the POST/REDIRECT/GET pattern.
Use Post Redirect Get design pattern.
In other words, the script that processes is not the one that displays the results.
You can user
$_SERVER['HTTP_REFERER'] to see your parent page, and detect if user is coming from thank you page
I'm doing a system where the pages are displayed by tabs (easytabs Plugin http://os.alfajango.com/easytabs/#tabs1-js)
At one point in the process it performs a query in the database, where we
see all the details of each item that appears. I'd like to go into the details of the item, click back to the (on broswer or a button) the page to return to the list displayed by the SQL query, just as with any single page, but currently it only displays a blank page.
I wonder how can I do to implement this solution using the layout tabs.
Thank you.
There are various ways to maintain UI state. One of them is using a "url hash". For example, you click tab 2, change the url hash to:
mypage.php#tab=2
Then if someone presses BACK and goes FORWARD, you use JavaScript to look at the URL has and determine that the user had previously pressed tab 2, so you run your own bit of code that triggers the same event.
I'm unfamiliar with "easytabs" so I'm sorry I can't help with the specific implementation details, but that's the gist of the technique.
this is a little bit tricky.
usually when someone clicks on a link that requires him to register, this person will be redirected to the registration page and then back to the last visited page. this is possible cause the link sent a GET key through the url to the registration.php which uses the key to go back to last visited page.
but i intend to use jquery ajax for registration. basically ive got 3 different php pages. all of them include the same header.php. and in header.php ive got a registration button which i have id tagged. when this button is clicked ( $(#registration_button).click()... ) jquery will show a box (a div that was hidden in the center of the browser) with registration information. then he will register and i will redirect him to the last visited page, that is to say the current one he sees. i have to refresh the php-page to be able to show all links that a registered user can see, thats why i have to use window.location.href.
now to the question. how do i let jquery know which page is the current one he is visiting? ive got 3 php-pages.
if there is something you dont understand, please free to ask.
or if you got suggestions of other solutions, let me know. but i really want to display the registration box right away without redirecting him to another page.
You can set cookies initially in php and then update/read them via js.
You could assign the page to a session and do it that way.
$_SESSION["page_visited"] = "x.php";
Make sure to use session_start on the pages using sessions. Then just redirect to the relevant page.
header('Location: http://www.example.com/'$_SESSION["page_visited"]);
I did a similar thing not two weeks ago, correct me if I'm wrong, but if you want the registration to direct to the page the user was on, after the user has been registered in the ajax just add:
window.location.href=window.location.href;
That way the after the registration is done, it just reloads where the member was with the environment of a logged in user. This method worked great for me.