WP Redirect is not working

You’re using a + sign for the first instance of string concatenation. Using a . instead should fix it. Additionally, WordPress provides some useful functions that might make this code easier: wp_redirect( add_query_arg( array( ‘post_type’ => ‘property’, ‘search_keyword’ => $search_keyword, ‘submit’ => ‘Search’, ‘price-min’ => $price_min, ‘price-max’ => $price_max, ‘city’ => $address_city, ‘state’ => $address_state, … Read more

Redirect to Page URL for non-members

You can use use wp_redirect for that. Here is a simple code, it redirects non-users to website homepage. You can redirect them to a error page or on signup page. <?php if( mgm_user_is( array(‘level1’, ‘level2’ ) ) ) { wp_redirect( home_url() ); exit; } else { // show content } ?>

Use wp_redirect without filter in plugin file

Not too sure what is really going on there, but one thing for sure your if statement is flawed, you should remove unneeded ELSE, should be like this: if (is_user_logged_in()) { if (isset($_GET[‘id’])) { $id = $_GET[‘id’]; show_submission($id); } elseif(has_submission()) { $url=”http://”.$_SERVER[“HTTP_HOST”].$_SERVER[“REQUEST_URI”].’?id=’.$get_submission_id(); header(‘Location: ‘.$url); } else { show_form(); } } OR like this: if (is_user_logged_in()) … Read more

Redirection problems

If you can log in to phpmyadmin, you can check the wp-options table in the database to check the value below, if it’s website.com, you must edit two line below is demo.websiteA.com

WordPress wp_redirect() not working after get_header();

wp_redirect() works by sending a Location header. Headers cannot be sent after output has been sent to the browser. So you cannot output any HTML before calling wp_redirect(). Using wp_redirect() after get_header() never would have worked, which is why it doesn’t work when you roll back. The only way it could’ve worked is if header.php … Read more

redirect to /wp-admin/edit.php instead of wp_redirect url

You just need to change the second parameter for get_edit_post_link(), which is $context and defaults to display. And that parameter determines how to output the ampersand character (i.e. &), which defaults to being encoded as &amp; (because the default context is that the URL is being displayed, hence the & is encoded). When using the … Read more

Can I trust user input in wp_redirect()?

You can never trust user input. Always prepare a value that you want use in your own code. Example: $path = filter_input( INPUT_SERVER, ‘REQUEST_URI’, FILTER_SANITIZE_URL ); if ( $path ) { $url=”http://old.example.com” . $path; $url_escaped = esc_url( $url ); $status = 301; $message = “Moved to <a href=”https://wordpress.stackexchange.com/questions/233824/$url_escaped”>$url_escaped</a>.”; wp_redirect( ‘http://old.example.com’. $path, $status ); wp_die( $message, … Read more