Custom redirects with using SQL

I wrote function for short url. Maybe it will be helpful for someone: function short_url(){ global $post; if (preg_match(‘/^http:\/\/example.com\/page\/[0-9]{1,4}$/’, “http://”.$_SERVER[“HTTP_HOST”] . $_SERVER[“REQUEST_URI”])) { $my_id = intval(preg_replace(‘/[^0-9]+/’, ”, $_SERVER[“REQUEST_URI”]), 10); global $wpdb; $myquery = $wpdb->get_row($wpdb->prepare(“SELECT * FROM wp_mytable WHERE ID=%d”, $my_id)); $short_url=”http://example.com/?page_id=”.$myquery->page_id.”&user_id=”.$myqery->user_id; wp_redirect($short_url); exit(); } } add_action( ‘template_redirect’, ‘short_url’ );

Redirect after empty register form

I think I found the solution myself. When I adjusted the declaration of the registration form: <form name=”registerform” id=”registerform” action=”<?php echo esc_url( site_url(‘wp-login.php?action=register’, ‘login_post’) ); ?>” method=”post” novalidate=”novalidate”> To the following: <form name=”registerform” id=”registerform” action=”<?php echo esc_url( site_url(‘wp-login.php?action=register&role=”.$_GET[“role’], ‘login_post’) ); ?>” method=”post” novalidate=”novalidate”> Then my problem is solved and the registration page is not redirected … Read more

Conditional redirection with logout

The wp_logout() function is pluggable. You should be able to write your own version and “overload” the Core function: function wp_logout() { $lid = get_current_user_id(); wp_destroy_current_session(); wp_clear_auth_cookie(); do_action( ‘wp_logout’ ); /** * Fires after a user is logged-out. * * @since 1.5.0 */ if (2 == $lid) { wp_redirect(home_url(“/redirectTo”)); exit; } }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)