How to create redirect for log in modal - wordpress

I'm trying to redirect this login button to a different page upon log in success. How do I do that without a plugin?
I tried checking the Woo Commerce settings and LearnDash settings and it does not change. I tried looking in the PHP file but am not really sure where to start.
picture of login modal

You can use the filter "woocommerce_login_redirect", which will redirect the user after successful login.
Follow the code below:
add_filter( 'woocommerce_login_redirect', 'my_login_redirect' );
function my_login_redirect( $redirect_to ) {
$redirect_to = 'http://www.example.com/my-account/';
return $redirect_to;
}
Hope this will help!

Related

Is it possible to customize the logout page or create a custom logout page in Wordpress?

At the moment if the user navigates to the default logout page it looks like this:
This is not consistent with the theme of my website so I would like this content inside my own custom page. Can this be done?
I have a plugin installed My Theme Plugin which is designed to let me specify a logout page but I do not know how to construct it.
Since this may help others, I'm adding my comments as an answer.
You need to initially use the logout_url filter - https://developer.wordpress.org/reference/hooks/logout_url/
This will allow you to set up a page when a user clicks on the logout link. Next, you simply create the page however you need to (basic WordPress page, special template, etc.).
On that page you would use wp_logout_url() to set the link for the Are you sure you want to logout text. e.g.
Logout
This would redirect the user to the home page after they've logged out.
Edit: shortcode to add to content:
function wpso58817718_add_logout_link( $atts ){
return 'Logout';
}
add_shortcode( 'logout_link', 'wpso58817718_add_logout_link' );
Then you can do [logout_link]
You'll have to update the end URL wp_logout_url( home_url() ) if you don't want it to go to the home page.
You can use below code to redirect user to your specific url after logout
add_action('wp_logout','ps_redirect_after_logout');
function ps_redirect_after_logout(){
wp_redirect( 'your url here' );
exit();
}

Login issue using dokan and revo wp theme

i installed dokan multi vendor plugin and revo theme on wordpress, whenever i use the multi-vendor account to login using the login widget, it takes to me the customer dashboard.
but on the regular login page ,it takes me to the correct url
I tried placing this code in themes/functions.php but didn't help, Pls I need assistance
add_filter( 'woocommerce_login_redirect', 'ckc_login_redirect', 10, 2 );
function ckc_login_redirect( $redirect_url, $user ) {
// Change this to the url to Updates page
if( $user->roles[0] == 'seller' ) {
return dokan_get_navigation_url(‘dashboard’);
}
return $redirect_url;
}
As you are not using the WooCommerce default my-account page for that reason, your vendor is not redirecting to the Dashboard page. I beleive that your theme login widget is using the default WordPress login function. So, I will suggest you to follow this function reference to redirect vendor to dashboard-https://codex.wordpress.org/Plugin_API/Filter_Reference/login_redirect
Thanks :)

Woocommerce Wordpress Plugin Change the Checkout Flow

I am using Woocommerce wordpress plugin in my site. When I am in the Cart page and click "proceed to checkout" I am now going to checkout page. I want to change this flow as below.
If the user is not logged in, he should be taken to a different url. If user is logged in he will go to checkout page as usual.
Any help is appreciated.
First you create a page where you want to redirect the guest user, for example register
then write this code in your functions.php
function restrict_user() {
if (! is_user_logged_in() && (is_checkout())) {
wp_redirect("http://your site url.com/register/");
exit;
}
}
add_action('template_redirect', 'restrict_user');
Hope this will help you...

WordPress not recognizing user is logged in

I want ONLY users who are logged in to view my WordPress site and the code I'm using is:
add_action('template_redirect', 'admin_redirect');
function admin_redirect() {
if ( !is_user_logged_in()) {
auth_redirect();
}
}
PROMLEM: if I send a hyperlink every time the user clicks it they are asked to sign in again.
Can you not just put
auth_redirect();
into your functions.php file?
This should redirect users who aren't logged in to the log in page but remember which page they were trying to access. Then when they log in it should redirect them to their destination page.
Is this not working?
From my understanding of auth_redirect(), you shouldn't have to place that check around it. The function actually handles that check itself as shown in the Codex
Also, I'd recommend moving this function into your header. By simply calling auth_redirect() in your header (which should be called on each and every page anyways), you can check if the user is logged in. If not, they should be bounced to the wp-login page.
Edit:
add_action( 'template_redirect', function() {
is_user_logged_in() || auth_redirect();
});
The folks over at the WordPress Exchange are much better with this sort of stuff. Found this link here.

wordpress profile builder not redirecting properly after registration

I am using "profile builder pro" plugin of wordpress in wordpress website and it works well except for "redirection after successfull registration" as it is redirecting to the same page.
here is a live link of it
http://www.selfmadesounds.com/dev3/register
Login redirection and register redirection i have set from backend and it is working for login but not for registration.
Any help will be pretty much accepted.
I dont have the pro version but had the same problem, i fixed it by hardcoding the redirect link.
Go to the page "wp-content/plugins/profile-builder/front-end/wppb.register.php"
Move to line 1026 and add the following:
$redirectLink = 'http://www.yourdomain.com/REDIRECT-PAGE';
Just simply overwrite the redirectLink before it go's and redirect.
Hope it helps
Please don't edit plugin files directly! Really bad practice.
You can solve this in a couple of ways, one way is to check if logged in and on a specific page then redirect to another page. There are nicer ways then hardcoding the urls and id, but this is better then editing plugin files directly.
Put this in your functions.php, change url and id to the one you need:
function isLoginPage() {
global $post;
return is_object($post) && (int) $post->ID === 1;
}
add_action('wp', 'redirectFromLoginpage');
function redirectFromLoginpage() {
if (isLoginPage()) {
global $wppb_login;
if (is_user_logged_in() || isset($wppb_login->ID)) { // Already logged in
wp_redirect(site_url() . '/redirect-to-this-url/');
die;
}
}
}

Resources