How to get login and logout urls
Hi
We are creating a custom landingpage for our users. We'll check if the user is signed in, and show a log in / log out button accordingly.
How do i get the login and logout urls? I see someone using:
<?php $aad= AADSSO::get_instance($settings); $aad->get_login_url(); // and get_logout_url(); ?>
What settings should be passed to get_instance()?
Update: We ended up with this:
$user = null;
if(is_user_logged_in()){
$user = wp_get_current_user();
}
$auth = apply_filters( 'authenticate', $user ,null,null);
//if( is_wp_error( $auth ) ) {
// echo '</br>'.$auth->get_error_message().'</br>';
//}
$stored_settings = get_option( 'aadsso_settings', null );
$aad= AADSSO::get_instance($stored_settings);
$loginUrl = $aad->get_login_url();
We got this working, and it's great. One thing, though: Login only works when the replyurl is mysite.com/wp-login.php. When changing it to something else, the plugin signs into ad, and reports no error. So we 'fixed' it by blocking wp-admin for relevant roles, and redirecting them to the landingpage.
Sorry for the delayed response. When you change the redirect URL, are you changing it in both this plugin's configuration and in the Azure AD app registration?
Yes. Both places.
What are you setting the redirect URL to? It's important that the URL you're redirecting to actually invoke the WordPress sign-in points where the plugin hooks into.