Parse Url, check params, and build it again:
$url = "http://localhost/sarkari/wp-login.php?action=logout&redirect_to=%2Fsarkari%2F&_wpnonce=b5e3b954df&redirect_to=http://localhost/sarkari/2017/06/01/new-sample-post/";
function trimUrlParams($url, array $params)
{
$parts = parse_url($url);
parse_str($parts['query'], $query);
$newQuery = array();
if (is_array($query) && sizeof($query) > 0 ) {
foreach ($query as $variable=>$value) {
if (in_array($variable, $params)) {
$newQuery[$variable] = $value;
}
}
}
return $parts['scheme']."://".$parts['host'].$parts['path']."?". http_build_query($newQuery);
}
$newUrl = trimUrlParams($url, array('action', 'redirect_to', '_wpnonce'));
Related Posts:
- Change register form action url
- How To Change Wp Register/Login URL Permanently To My Custom Page
- Changed Wordress Address URL Accidently
- redirect_to not Including Hashtag from URL
- Remember me doesn’t work with www?
- Can’t access wordpress mgt dashboard until propogation finished?
- Is there any way to rename or hide wp-login.php?
- Preventing session timeout
- I can’t access my site via wp-admin
- how to display the wordpress login and register forms on a page?
- Website Visible only to Registered users
- How do I use add_action from a class method?
- I want to disable E-Mail verifcation / activation when a user signs up for my WordPress site
- How do I check if a post is private?
- Is it possible to use a forgot password url filter?
- Action wp_login_failed not working if only one field is filled out
- Display last login time
- Intentionally Force Failed Login WordPress
- How do I turn off the ability to login?
- What hooks should I use for pre-login and pre-registration actions?
- WordPress Login Footer URL
- Save last login date in global before change it?
- how to update current logged user username
- Custom Reset Password & Forgot Password Front End Forms
- Admin user getting message ‘You need a higher level of permission’
- How to implement Google reCaptcha without installing a plugin?
- Problem with logging in WP users automatically
- advance membership managment
- Logins through alias
- Is back-end access not required for an app to post to my blog?
- Remove WordPress Login Animation
- Redirect users to a front end wp login page
- Redirecting or displaying a message on first login
- Deny a user role to log in after register
- wp_get_referer not working properly after wp_redirect
- Login Button CSS
- Force Users to Login – loop problem
- Is there a better way than checking user is logged in to show or hide adminbar?
- How to redirect after login getting a variable from url (for example with the language)
- How do I replace “Username” in the WordPress login form?
- How can I do a URL redirection when an user uses wrong login details?
- Show errors on custom login form [duplicate]
- Change login_message using title
- Changing WP login credential [closed]
- Login with serialized password
- Index page and random posts needs a forced refresh in order to show new content
- How to change wordpress Log In text
- Single sign on with custom site
- By registering always make uppercase the first letter of the login
- Best option to implement external register/login to WP from self-made API
- Enqueue new login style sheet
- WordPress Conditional Login Links
- Secure login on wordpress [closed]
- Do more action after login successfully
- How can I password protect a WordPress site without requiring users to log in?
- Can’t login to my own website
- I cannot login and am getting this error message. .
- Can I Get User ID at Login?
- Cannot log into migrated site
- WordPress SSL not working [closed]
- I want login using email not username wordpress front end
- How to Remove default “Login” link
- How to unpublish my new site while working on it?
- How to force “remember me” users to login again?
- Reset Password Limit not working
- User not able to sign in after wp_authenticate() and wp_signon() wordpress
- WordPress site login Redirect
- Thank You Page Layout Differs on User Logged In Status
- On Homepage “is_user_logged_in()” function is not working after login and it is working after refresh the page?
- Problem in auto login after registration
- Cant reset password my wordpress password not even with phpMyAdmin
- Get WordPress logged in username from root domain when WP is installed in a subfolder
- How to invalidate `password reset key` after being used
- wp-cron event doesn’t run when custom login API is enabled
- Does it make sense to check a nonce on user log in?
- Special link for no automatic login (no username and no password)
- Global login to password protected pages
- Disable / Remove Password for Login WordPress
- WordPress Auto Login From Email Link
- Building a custom login form – encountering issues
- Making sure two different wordpress website has auto login
- Site login failed due to strange warning
- How do i Redirect specific user(WooCommerce Sign-in not wordpress admin page sign-in) to specific page
- Chosen user password in registration is not being accepted on Login
- Improvements to “limit login attempts” plugin
- Add a required field to Registration
- loging to Admin page not working at all
- Can’t login through wp-login.php on fresh installation
- WordPress Cookies – wp_set_auth_cookie
- Authenticate return value
- Front-end login problem: requires re-authorization when accessing dashboard
- Using wp_login_form passowrd as undefined
- Redirect non-members to about/intro page
- When trying to login if already logged in, form just shakes – error message remains empty
- Handle POST request sent from an external site for login?
- Can not login after moving to cloudflare and adding rules
- Inconsistent login state
- Can i hide a dynamically created div to logged out users?
- Why am I not able to login to the admin
- WP behind haproxy weirdness