I have two custom templates saved in my templates folder.
One's called xxxx.php and another is xxxx-test.php.
They are the exact same files except one points to a live API and the other a test API.
In my xxxx.php file I have something like this:
if(empty($current_user->user_email)){
header("Location:/wp-login.php");die;
}
I dont have this in the xxxx-test.php.
I want to be able to access xxxx.php only when logged in hence why im checking for the email. For the xxxx-test.php I'd like to give full access.
My problem is that everytime i try to go to the xxxx.php page i get redirected to xxxx-test.php
Anyone know how to stop wordpress from doing this?
Related
I have a file structure like
example.com/mywordpress/ --contains WordPress
example.com/custompreview.php --preview getter outside wordpress
I am using wp-load.php to load wordpres and using its contents. I am able to recive published posts with no problem, I even know how to make query for previews but when preview get parameters comes to the script outside the wordpress folder (custompreview.php) obviously the wp-load.php calls exit and shows only access error message.
Example is worth thousand words:
example.com/custompreview.php?preview=true&preview_id=64&preview_nonce=1f2477c5d2&post_format=standard
Shows only message "You do not have permission to preview drafts"
What is causing this? What is the wp-load.php checking for? How to fix this? :)
If you are getting this while logged in -
the session cookie may be limited to the /mywordpress folder.
Unless explicitly specified, the cookie will be valid in the subdirectory it was set in (and all children).
I'm not sure whether it is possible to change WP's session cookie behaviour, but it may help to put the PHP file inside /mywordpress.
I don't even really know how to ask this question or what this would be called or if it's even possible. I've tried searching but I guess I just can't word the question properly.
What I'm trying to do is have a URL, say mydomain.com/blog/2012/12, but without the folder structure on my server public_html/blog/2012/12/index.php
Well, public_html/blog/index.php exists, but for the rest, I would like when visitors go to the page mydomain.com/blog/2012/12, for the web site to load an index.php file from somewhere else on the server, and show blog archives for December 2012 without a 404 page coming up because that folder doesn't actually exist.
ie, I don't want to have to create folders for every year/month.
Is this possible? I'm sure it's possible, I just can't figure out how to search for this particular topic.
I am creating an application in PHP.
One thing I want to do is make it so that if a user types in www.example.com/app/rrr.php where app is the main directory of my application and rrr.php does not exist, that either the program does not go anywhere or use ErrorDocuments in .htaccess to redirect back to the previous page. Thus far the only way I have been able to get this is to add this in my .htaccess:
ErrorDocument 404 C:\Users\Chris\Desktop\wamp\www\Master\errorcode.php
When I try to go to a page that does not exist (by typing in the address area), the program does not attempt to go to it. On a page that does exist (if I type in a php file that I have made) the program advances normally. My problem is that I doubt this will work for users who install it themselves, and I was wondering if anyone had ideas as to how to make this work for everyone.
Couln't understand your question fully, but what I think is,
You should direct user to 404 page where you will check if there is any referer then give a link along with 404 page something like You might want to go back, and if there is no referer just show 404 page.
I have a problem.
I ma moving a system from one server to another and I came across a peculiar problem. There are some pages placed in a subfolder like these:
xttp://test.domain.com/admin/oders.php
xttp://test.domain.com/admin/users.php
xttp://test.domain.com/admin/whatever.php
Now, when I move around the pages, via some simple menu with links I get most of the times correct hits. But from time to time I end up on say:
xttp://test.domain.com/admin/admin/oders.php - which obviously causes 404
When I go back to previous page and press the link again it again works all right. Also when I hover over the links they always show proper paths regardless of whether I am going to get 404 or not. All links are dynamically generated by the scripts but they work perfectly on old server and as I say to a naked eye it all looks OK, right until I press the link.
Anyone has an idea where to look for a bug or which tool to use to see what is happening when I press the link? URL mod rewrite? Domain configuration? I am at a loss.
It sounds like the scripts are getting confused between
[xttp://test.domain.com]/admin/file.php
admin/file.php
file.php
Without seeing how the URLs are generated it's impossible to say how this is happening.
I have some redirects in place from our previous site that used CakePHP. The new site has plain PHP pages. When trying to redirect the following in an .htaccess file I am having problems:
Redirect 301 /old-page-here http://samesitename.com/somedirectory/newfilename.php
The /old-page-here had the extension .ctp. When I run this in my browser I get a loop with newfilename.php appearing over and over again (as well as the other webaddress information - but not repeated).
I was having a similiarish problem with when CakePHP put page numbers in, e.g.
Redirect 301 /olddirectory/old-page-here/2 http://samesitename.com/somedirectory/newfilename-2.php
When it would add both directories into the webaddress. Redirecting pages that were within the webroot directory (pulled from the database) that did not end in a slash-number have directed OK.
Any ideas what is going wrong?
Maybe this could come in handy for building your new urls. As for your trouble with redirecting when cakephp was still installed: I can imagine that this is somewhat complicated to achieve from "outside", as somewhere in the process cake's dispatcher dissolves the address into controller,action, parameters. From the "inside", you can do
redirects with a status code.