<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"lang="en-US" xml:lang="en-US" itemscope="itemscope" itemtype="http://schema.org/Article">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link rel="stylesheet" href="https://blog.blackbam.at/wp-content/themes/SilentWoodsByBlackbam/style.css" type="text/css" media="screen" />
        <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
        <link rel="stylesheet" href="https://blog.blackbam.at/wp-content/themes/SilentWoodsByBlackbam/a2-bigmobile.css" type="text/css" media="screen and (max-width: 860px)" />
        <link rel="stylesheet" href="https://blog.blackbam.at/wp-content/themes/SilentWoodsByBlackbam/a3-smallmobile.css" type="text/css" media="screen and (max-width: 560px)" />
        
        <!--[if lt IE 8]><link rel="stylesheet" href="https://blog.blackbam.at/wp-content/themes/SilentWoodsByBlackbam/ie.css" type="text/css" media="screen" /><![endif]-->
        <link rel="shortcut icon" href="https://blog.blackbam.at/wp-content/themes/SilentWoodsByBlackbam/images/favicon.ico" type="image/x-icon" />
        <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="https://blog.blackbam.at/feed/" />
        <link rel="alternate" type="text/xml" title="RSS .92" href="https://blog.blackbam.at/feed/rss/" />
        <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="https://blog.blackbam.at/feed/atom/" />
        <link rel="pingback" href="https://blog.blackbam.at/xmlrpc.php" />
<meta name='robots' content='max-image-preview:large' />
	<style>img:is([sizes="auto" i], [sizes^="auto," i]) { contain-intrinsic-size: 3000px 1500px }</style>
	<link rel='dns-prefetch' href='//www.googletagmanager.com' />
<link rel='dns-prefetch' href='//static.addtoany.com' />
<link rel="alternate" type="application/rss+xml" title="Blackbams Blog &raquo; WordPress custom external authentication login/logout PHP script Comments Feed" href="https://blog.blackbam.at/2011/06/09/wordpress-custom-external-authentication-loginlogout-php-script/feed/" />
    <meta name="robots" content="all,index,follow,noodp" />
    <!-- BEGIN CIS HEADER -->

    <!-- Standard Tags -->
    <title itemprop="name">WordPress custom external authentication login/logout PHP script • authentication custom script login logout wp_authenticate  • Blackbams Blog</title>
    <meta name="description" lang="en-US" content="WordPress, WP Scripts • Recently I was confronted with the problem to have multiple user types on a WordPress Blog who needed to be logged in using an external service/authentication mechanism partly. But they all had [...]" />
    <meta name="author" content="David Stöckl" />
    <meta name="publisher" content="David Stöckl" />

    <!-- Search Engines: Schema -->
    <meta itemprop="description" content="WordPress, WP Scripts • Recently I was confronted with the problem to have multiple user types on a WordPress Blog who needed to be logged in using an external service/authentication mechanism partly. But they all had [...]" />
    <meta itemprop="primaryImageOfPage" content="https://blog.blackbam.at/wp-content/uploads/2019/03/imagex.jpg" />
    
    <!-- Open Graph -->
    <meta property="og:locale" content="en_US"/>
    <meta property="og:site_name" content="Blackbams Blog" />
    <meta property="og:type" content="website" />
    <meta property="og:title" content="WordPress custom external authentication login/logout PHP script • authentication custom script login logout wp_authenticate  • Blackbams Blog" />
    <meta property="og:description" content="WordPress, WP Scripts • Recently I was confronted with the problem to have multiple user types on a WordPress Blog who needed to be logged in using an external service/authentication mechanism partly. But they all had [...]" />
    <meta property="og:url" content="https://blog.blackbam.at/2011/06/09/wordpress-custom-external-authentication-loginlogout-php-script/" />
    <meta property="og:image" content="https://blog.blackbam.at/wp-content/uploads/2019/03/imagex.jpg" />
    <meta property="og:updated_time" content="2011-10-05T19:25:12+0000" />
    <!-- Twitter -->
    <meta name="twitter:title" content="WordPress custom external authentication login/logout PHP script • authentication custom script login logout wp_authenticate  • Blackbams Blog"/>
    <meta name="twitter:description" content="WordPress, WP Scripts • Recently I was confronted with the problem to have multiple user types on a WordPress Blog who needed to be logged in using an external service/authentication mechanism partly. But they all had [...]"/>
    <meta name="twitter:url" content="https://blog.blackbam.at/2011/06/09/wordpress-custom-external-authentication-loginlogout-php-script/"/>
    <meta name="twitter:card" content="summary_large_image"/>
    <meta name="twitter:image" content="https://blog.blackbam.at/wp-content/uploads/2019/03/imagex.jpg">
    
    <link rel="pingback" href="https://blog.blackbam.at/xmlrpc.php" />
    <link rel="shortlink" href="" />
            <link itemprop="url" rel="canonical" href="https://blog.blackbam.at/2011/06/09/wordpress-custom-external-authentication-loginlogout-php-script/" />
    
    <!-- app colors -->
    <meta name="msapplication-TileColor" content="#272c36">
    <meta name="theme-color" content="#272c36">

    <!-- favicon & app icon -->
                <link rel="apple-touch-icon" sizes="57x57" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=57&h=57&q=80&zc=1">
                    <link rel="apple-touch-icon" sizes="60x60" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=60&h=60&q=80&zc=1">
                    <link rel="apple-touch-icon" sizes="72x72" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=72&h=72&q=80&zc=1">
                    <link rel="apple-touch-icon" sizes="76x76" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=76&h=76&q=80&zc=1">
                    <link rel="apple-touch-icon" sizes="114x114" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=114&h=114&q=80&zc=1">
                    <link rel="apple-touch-icon" sizes="120x120" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=120&h=120&q=80&zc=1">
                    <link rel="apple-touch-icon" sizes="144x144" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=144&h=144&q=80&zc=1">
                    <link rel="apple-touch-icon" sizes="152x152" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=152&h=152&q=80&zc=1">
                    <link rel="apple-touch-icon" sizes="180x180" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=180&h=180&q=80&zc=1">
                    <link rel="icon" type="image/png" sizes="192x192" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=192&h=192&q=80&zc=1">
                    <link rel="icon" type="image/png" sizes="32x32" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=32&h=32&q=80&zc=1">
                    <link rel="icon" type="image/png" sizes="96x96" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=96&h=96&q=80&zc=1">
                    <link rel="icon" type="image/png" sizes="60x60" href="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/imageserver/imageserver.php?src=https://blog.blackbam.at/wp-content/uploads/2019/03/favicon-xlarge.jpg&w=60&h=60&q=80&zc=1">
            <!-- END CIS HEADER -->
    <link rel='stylesheet' id='cis-gdpr-footer-css' href='https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/addons/gdpr-footer/gdpr-footer.css?ver=173' type='text/css' media='all' />
<link rel='stylesheet' id='wp-block-library-css' href='https://blog.blackbam.at/wp-includes/css/dist/block-library/style.min.css?ver=6.8.1' type='text/css' media='all' />
<style id='classic-theme-styles-inline-css' type='text/css'>
/*! This file is auto-generated */
.wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none}
</style>
<style id='global-styles-inline-css' type='text/css'>
:root{--wp--preset--aspect-ratio--square: 1;--wp--preset--aspect-ratio--4-3: 4/3;--wp--preset--aspect-ratio--3-4: 3/4;--wp--preset--aspect-ratio--3-2: 3/2;--wp--preset--aspect-ratio--2-3: 2/3;--wp--preset--aspect-ratio--16-9: 16/9;--wp--preset--aspect-ratio--9-16: 9/16;--wp--preset--color--black: #000000;--wp--preset--color--cyan-bluish-gray: #abb8c3;--wp--preset--color--white: #ffffff;--wp--preset--color--pale-pink: #f78da7;--wp--preset--color--vivid-red: #cf2e2e;--wp--preset--color--luminous-vivid-orange: #ff6900;--wp--preset--color--luminous-vivid-amber: #fcb900;--wp--preset--color--light-green-cyan: #7bdcb5;--wp--preset--color--vivid-green-cyan: #00d084;--wp--preset--color--pale-cyan-blue: #8ed1fc;--wp--preset--color--vivid-cyan-blue: #0693e3;--wp--preset--color--vivid-purple: #9b51e0;--wp--preset--gradient--vivid-cyan-blue-to-vivid-purple: linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%);--wp--preset--gradient--light-green-cyan-to-vivid-green-cyan: linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%);--wp--preset--gradient--luminous-vivid-amber-to-luminous-vivid-orange: linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%);--wp--preset--gradient--luminous-vivid-orange-to-vivid-red: linear-gradient(135deg,rgba(255,105,0,1) 0%,rgb(207,46,46) 100%);--wp--preset--gradient--very-light-gray-to-cyan-bluish-gray: linear-gradient(135deg,rgb(238,238,238) 0%,rgb(169,184,195) 100%);--wp--preset--gradient--cool-to-warm-spectrum: linear-gradient(135deg,rgb(74,234,220) 0%,rgb(151,120,209) 20%,rgb(207,42,186) 40%,rgb(238,44,130) 60%,rgb(251,105,98) 80%,rgb(254,248,76) 100%);--wp--preset--gradient--blush-light-purple: linear-gradient(135deg,rgb(255,206,236) 0%,rgb(152,150,240) 100%);--wp--preset--gradient--blush-bordeaux: linear-gradient(135deg,rgb(254,205,165) 0%,rgb(254,45,45) 50%,rgb(107,0,62) 100%);--wp--preset--gradient--luminous-dusk: linear-gradient(135deg,rgb(255,203,112) 0%,rgb(199,81,192) 50%,rgb(65,88,208) 100%);--wp--preset--gradient--pale-ocean: linear-gradient(135deg,rgb(255,245,203) 0%,rgb(182,227,212) 50%,rgb(51,167,181) 100%);--wp--preset--gradient--electric-grass: linear-gradient(135deg,rgb(202,248,128) 0%,rgb(113,206,126) 100%);--wp--preset--gradient--midnight: linear-gradient(135deg,rgb(2,3,129) 0%,rgb(40,116,252) 100%);--wp--preset--font-size--small: 13px;--wp--preset--font-size--medium: 20px;--wp--preset--font-size--large: 36px;--wp--preset--font-size--x-large: 42px;--wp--preset--spacing--20: 0.44rem;--wp--preset--spacing--30: 0.67rem;--wp--preset--spacing--40: 1rem;--wp--preset--spacing--50: 1.5rem;--wp--preset--spacing--60: 2.25rem;--wp--preset--spacing--70: 3.38rem;--wp--preset--spacing--80: 5.06rem;--wp--preset--shadow--natural: 6px 6px 9px rgba(0, 0, 0, 0.2);--wp--preset--shadow--deep: 12px 12px 50px rgba(0, 0, 0, 0.4);--wp--preset--shadow--sharp: 6px 6px 0px rgba(0, 0, 0, 0.2);--wp--preset--shadow--outlined: 6px 6px 0px -3px rgba(255, 255, 255, 1), 6px 6px rgba(0, 0, 0, 1);--wp--preset--shadow--crisp: 6px 6px 0px rgba(0, 0, 0, 1);}:where(.is-layout-flex){gap: 0.5em;}:where(.is-layout-grid){gap: 0.5em;}body .is-layout-flex{display: flex;}.is-layout-flex{flex-wrap: wrap;align-items: center;}.is-layout-flex > :is(*, div){margin: 0;}body .is-layout-grid{display: grid;}.is-layout-grid > :is(*, div){margin: 0;}:where(.wp-block-columns.is-layout-flex){gap: 2em;}:where(.wp-block-columns.is-layout-grid){gap: 2em;}:where(.wp-block-post-template.is-layout-flex){gap: 1.25em;}:where(.wp-block-post-template.is-layout-grid){gap: 1.25em;}.has-black-color{color: var(--wp--preset--color--black) !important;}.has-cyan-bluish-gray-color{color: var(--wp--preset--color--cyan-bluish-gray) !important;}.has-white-color{color: var(--wp--preset--color--white) !important;}.has-pale-pink-color{color: var(--wp--preset--color--pale-pink) !important;}.has-vivid-red-color{color: var(--wp--preset--color--vivid-red) !important;}.has-luminous-vivid-orange-color{color: var(--wp--preset--color--luminous-vivid-orange) !important;}.has-luminous-vivid-amber-color{color: var(--wp--preset--color--luminous-vivid-amber) !important;}.has-light-green-cyan-color{color: var(--wp--preset--color--light-green-cyan) !important;}.has-vivid-green-cyan-color{color: var(--wp--preset--color--vivid-green-cyan) !important;}.has-pale-cyan-blue-color{color: var(--wp--preset--color--pale-cyan-blue) !important;}.has-vivid-cyan-blue-color{color: var(--wp--preset--color--vivid-cyan-blue) !important;}.has-vivid-purple-color{color: var(--wp--preset--color--vivid-purple) !important;}.has-black-background-color{background-color: var(--wp--preset--color--black) !important;}.has-cyan-bluish-gray-background-color{background-color: var(--wp--preset--color--cyan-bluish-gray) !important;}.has-white-background-color{background-color: var(--wp--preset--color--white) !important;}.has-pale-pink-background-color{background-color: var(--wp--preset--color--pale-pink) !important;}.has-vivid-red-background-color{background-color: var(--wp--preset--color--vivid-red) !important;}.has-luminous-vivid-orange-background-color{background-color: var(--wp--preset--color--luminous-vivid-orange) !important;}.has-luminous-vivid-amber-background-color{background-color: var(--wp--preset--color--luminous-vivid-amber) !important;}.has-light-green-cyan-background-color{background-color: var(--wp--preset--color--light-green-cyan) !important;}.has-vivid-green-cyan-background-color{background-color: var(--wp--preset--color--vivid-green-cyan) !important;}.has-pale-cyan-blue-background-color{background-color: var(--wp--preset--color--pale-cyan-blue) !important;}.has-vivid-cyan-blue-background-color{background-color: var(--wp--preset--color--vivid-cyan-blue) !important;}.has-vivid-purple-background-color{background-color: var(--wp--preset--color--vivid-purple) !important;}.has-black-border-color{border-color: var(--wp--preset--color--black) !important;}.has-cyan-bluish-gray-border-color{border-color: var(--wp--preset--color--cyan-bluish-gray) !important;}.has-white-border-color{border-color: var(--wp--preset--color--white) !important;}.has-pale-pink-border-color{border-color: var(--wp--preset--color--pale-pink) !important;}.has-vivid-red-border-color{border-color: var(--wp--preset--color--vivid-red) !important;}.has-luminous-vivid-orange-border-color{border-color: var(--wp--preset--color--luminous-vivid-orange) !important;}.has-luminous-vivid-amber-border-color{border-color: var(--wp--preset--color--luminous-vivid-amber) !important;}.has-light-green-cyan-border-color{border-color: var(--wp--preset--color--light-green-cyan) !important;}.has-vivid-green-cyan-border-color{border-color: var(--wp--preset--color--vivid-green-cyan) !important;}.has-pale-cyan-blue-border-color{border-color: var(--wp--preset--color--pale-cyan-blue) !important;}.has-vivid-cyan-blue-border-color{border-color: var(--wp--preset--color--vivid-cyan-blue) !important;}.has-vivid-purple-border-color{border-color: var(--wp--preset--color--vivid-purple) !important;}.has-vivid-cyan-blue-to-vivid-purple-gradient-background{background: var(--wp--preset--gradient--vivid-cyan-blue-to-vivid-purple) !important;}.has-light-green-cyan-to-vivid-green-cyan-gradient-background{background: var(--wp--preset--gradient--light-green-cyan-to-vivid-green-cyan) !important;}.has-luminous-vivid-amber-to-luminous-vivid-orange-gradient-background{background: var(--wp--preset--gradient--luminous-vivid-amber-to-luminous-vivid-orange) !important;}.has-luminous-vivid-orange-to-vivid-red-gradient-background{background: var(--wp--preset--gradient--luminous-vivid-orange-to-vivid-red) !important;}.has-very-light-gray-to-cyan-bluish-gray-gradient-background{background: var(--wp--preset--gradient--very-light-gray-to-cyan-bluish-gray) !important;}.has-cool-to-warm-spectrum-gradient-background{background: var(--wp--preset--gradient--cool-to-warm-spectrum) !important;}.has-blush-light-purple-gradient-background{background: var(--wp--preset--gradient--blush-light-purple) !important;}.has-blush-bordeaux-gradient-background{background: var(--wp--preset--gradient--blush-bordeaux) !important;}.has-luminous-dusk-gradient-background{background: var(--wp--preset--gradient--luminous-dusk) !important;}.has-pale-ocean-gradient-background{background: var(--wp--preset--gradient--pale-ocean) !important;}.has-electric-grass-gradient-background{background: var(--wp--preset--gradient--electric-grass) !important;}.has-midnight-gradient-background{background: var(--wp--preset--gradient--midnight) !important;}.has-small-font-size{font-size: var(--wp--preset--font-size--small) !important;}.has-medium-font-size{font-size: var(--wp--preset--font-size--medium) !important;}.has-large-font-size{font-size: var(--wp--preset--font-size--large) !important;}.has-x-large-font-size{font-size: var(--wp--preset--font-size--x-large) !important;}
:where(.wp-block-post-template.is-layout-flex){gap: 1.25em;}:where(.wp-block-post-template.is-layout-grid){gap: 1.25em;}
:where(.wp-block-columns.is-layout-flex){gap: 2em;}:where(.wp-block-columns.is-layout-grid){gap: 2em;}
:root :where(.wp-block-pullquote){font-size: 1.5em;line-height: 1.6;}
</style>
<link rel='stylesheet' id='titan-adminbar-styles-css' href='https://blog.blackbam.at/wp-content/plugins/anti-spam/assets/css/admin-bar.css?ver=7.3.8' type='text/css' media='all' />
<link rel='stylesheet' id='bb-taps-editor-style-shared-css' href='https://blog.blackbam.at/wp-content/themes/SilentWoodsByBlackbam/editor-style-shared.css?ver=6.8.1' type='text/css' media='all' />
<style id='akismet-widget-style-inline-css' type='text/css'>

			.a-stats {
				--akismet-color-mid-green: #357b49;
				--akismet-color-white: #fff;
				--akismet-color-light-grey: #f6f7f7;

				max-width: 350px;
				width: auto;
			}

			.a-stats * {
				all: unset;
				box-sizing: border-box;
			}

			.a-stats strong {
				font-weight: 600;
			}

			.a-stats a.a-stats__link,
			.a-stats a.a-stats__link:visited,
			.a-stats a.a-stats__link:active {
				background: var(--akismet-color-mid-green);
				border: none;
				box-shadow: none;
				border-radius: 8px;
				color: var(--akismet-color-white);
				cursor: pointer;
				display: block;
				font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen-Sans', 'Ubuntu', 'Cantarell', 'Helvetica Neue', sans-serif;
				font-weight: 500;
				padding: 12px;
				text-align: center;
				text-decoration: none;
				transition: all 0.2s ease;
			}

			/* Extra specificity to deal with TwentyTwentyOne focus style */
			.widget .a-stats a.a-stats__link:focus {
				background: var(--akismet-color-mid-green);
				color: var(--akismet-color-white);
				text-decoration: none;
			}

			.a-stats a.a-stats__link:hover {
				filter: brightness(110%);
				box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06), 0 0 2px rgba(0, 0, 0, 0.16);
			}

			.a-stats .count {
				color: var(--akismet-color-white);
				display: block;
				font-size: 1.5em;
				line-height: 1.4;
				padding: 0 13px;
				white-space: nowrap;
			}
		
</style>
<link rel='stylesheet' id='newsletter-css' href='https://blog.blackbam.at/wp-content/plugins/newsletter/style.css?ver=8.8.5' type='text/css' media='all' />
<link rel='stylesheet' id='addtoany-css' href='https://blog.blackbam.at/wp-content/plugins/add-to-any/addtoany.min.css?ver=1.16' type='text/css' media='all' />
<script type="text/javascript" src="https://blog.blackbam.at/wp-includes/js/jquery/jquery.min.js?ver=3.7.1" id="jquery-core-js"></script>
<script type="text/javascript" src="https://blog.blackbam.at/wp-includes/js/jquery/jquery-migrate.min.js?ver=3.4.1" id="jquery-migrate-js"></script>
<script type="text/javascript" id="cis-js-globals-js-extra">
/* <![CDATA[ */
var CISJSGLOBALS = {"template_url":"https:\/\/blog.blackbam.at\/wp-content\/themes\/SilentWoodsByBlackbam","imageserver_url":"https:\/\/blog.blackbam.at\/wp-content\/mu-plugins\/code-is-passion-libraries-plugin\/imageserver\/imageserver.php","default_image":"https:\/\/blog.blackbam.at\/wp-content\/mu-plugins\/code-is-passion-libraries-plugin\/images\/default.svg"};
/* ]]> */
</script>
<script type="text/javascript" src="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/base/codeispassion-libraries.js?ver=1" id="cis-js-globals-js"></script>
<script type="text/javascript" id="lib-cis-il8n-js-extra">
/* <![CDATA[ */
var CIS_I8 = {"enable":"1","cur":"en","default":"en","lan":["en","de"],"suffixes":["","____de"],"lanmap":{"en":"English","de":"Deutsch"},"sep":"____","qtrans":""};
/* ]]> */
</script>
<script type="text/javascript" src="https://blog.blackbam.at/wp-content/mu-plugins/code-is-passion-libraries-plugin/il8n/js/lib_cis_il8n.js?ver=173" id="lib-cis-il8n-js"></script>
<script src='https://www.googletagmanager.com/gtag/js?id=UA-136689836-1&ver=1' async></script><script type="text/javascript" id="cis-seo-google-analytics-header-js-after">
/* <![CDATA[ */
window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'UA-136689836-1');
/* ]]> */
</script>
<script type="text/javascript" id="addtoany-core-js-before">
/* <![CDATA[ */
window.a2a_config=window.a2a_config||{};a2a_config.callbacks=[];a2a_config.overlays=[];a2a_config.templates={};
/* ]]> */
</script>
<script type="text/javascript" defer src="https://static.addtoany.com/menu/page.js" id="addtoany-core-js"></script>
<script type="text/javascript" defer src="https://blog.blackbam.at/wp-content/plugins/add-to-any/addtoany.min.js?ver=1.1" id="addtoany-jquery-js"></script>
<link rel="https://api.w.org/" href="https://blog.blackbam.at/wp-json/" /><link rel="alternate" title="JSON" type="application/json" href="https://blog.blackbam.at/wp-json/wp/v2/posts/1424" /><link rel="EditURI" type="application/rsd+xml" title="RSD" href="https://blog.blackbam.at/xmlrpc.php?rsd" />
<meta name="generator" content="WordPress 6.8.1" />
<link rel='shortlink' href='https://blog.blackbam.at/?p=1424' />
<link rel="alternate" title="oEmbed (JSON)" type="application/json+oembed" href="https://blog.blackbam.at/wp-json/oembed/1.0/embed?url=https%3A%2F%2Fblog.blackbam.at%2F2011%2F06%2F09%2Fwordpress-custom-external-authentication-loginlogout-php-script%2F" />
<link rel="alternate" title="oEmbed (XML)" type="text/xml+oembed" href="https://blog.blackbam.at/wp-json/oembed/1.0/embed?url=https%3A%2F%2Fblog.blackbam.at%2F2011%2F06%2F09%2Fwordpress-custom-external-authentication-loginlogout-php-script%2F&#038;format=xml" />
	<style type="text/css">
		.chi_display_header {
			background-repeat:no-repeat;
			background-position:center center;
		}
	</style>
<style type="text/css">
.qtranxs_flag_de {background-image: url(https://blog.blackbam.at/wp-content/plugins/qtranslate-xt/flags/de.png); background-repeat: no-repeat;}
.qtranxs_flag_en {background-image: url(https://blog.blackbam.at/wp-content/plugins/qtranslate-xt/flags/gb.png); background-repeat: no-repeat;}
</style>
<link hreflang="de" href="https://blog.blackbam.at/de/2011/06/09/wordpress-custom-external-authentication-loginlogout-php-script/" rel="alternate" />
<link hreflang="en" href="https://blog.blackbam.at/en/2011/06/09/wordpress-custom-external-authentication-loginlogout-php-script/" rel="alternate" />
<link hreflang="x-default" href="https://blog.blackbam.at/2011/06/09/wordpress-custom-external-authentication-loginlogout-php-script/" rel="alternate" />
<meta name="generator" content="qTranslate-XT 3.5.3" />
<style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>    </head>
    <body class="wp-singular post-template-default single single-post postid-1424 single-format-standard wp-theme-SilentWoodsByBlackbam">
        <div id="container">
            <div id="content">
                <div id="leftcontent">
                </div>
                <div id="rightcontent">
                </div>
                <div id="ctborder">
                    <div id="incontent">
                        <div id="inincontent">
                            <div id="head">
                                <div id="headings">
                                    <div id="logo">
                                        <img id="logo_img" src="https://blog.blackbam.at/wp-content/themes/SilentWoodsByBlackbam/images/logo.jpg" width="70" height="70" alt="" />
                                    </div>
                                    <div id="bloginfo">
                                        <h1 id="blogtitle"><a href="https://blog.blackbam.at">Blackbams Blog</a></h1>
                                        <h3 id="blogdescription">development &#8211; digital arts &#8211; internet</h3>
                                    </div>
                                    <!-- bloginfo div -->
									<style type="text/css">
.qtranxs_widget ul { margin: 0; }
.qtranxs_widget ul li
{
display: inline; /* horizontal list, use "list-item" or other appropriate value for vertical list */
list-style-type: none; /* use "initial" or other to enable bullets */
margin: 0 5px 0 0; /* adjust spacing between items */
opacity: 0.5;
-o-transition: 1s ease opacity;
-moz-transition: 1s ease opacity;
-webkit-transition: 1s ease opacity;
transition: 1s ease opacity;
}
/* .qtranxs_widget ul li span { margin: 0 5px 0 0; } */ /* other way to control spacing */
.qtranxs_widget ul li.active { opacity: 0.8; }
.qtranxs_widget ul li:hover { opacity: 1; }
.qtranxs_widget img { box-shadow: none; vertical-align: middle; display: initial; }
.qtranxs_flag { height:12px; width:18px; display:block; }
.qtranxs_flag_and_text { padding-left:20px; }
.qtranxs_flag span { display:none; }
</style>
<div id="sidebar_header">
<ul class="language-chooser language-chooser-both qtranxs_language_chooser" id="qtranslate-5-chooser">
<li><a href="https://blog.blackbam.at/de/2011/06/09/wordpress-custom-external-authentication-loginlogout-php-script/" class="qtranxs_flag_de qtranxs_flag_and_text" title="Deutsch (de)"><span>Deutsch</span></a></li>
<li class="active"><a href="https://blog.blackbam.at/en/2011/06/09/wordpress-custom-external-authentication-loginlogout-php-script/" class="qtranxs_flag_en qtranxs_flag_and_text" title="English (en)"><span>English</span></a></li>
</ul><div class="qtranxs_widget_end"></div>
</div>       
									<div id="daily_featured">
										<p>Knowledge is free. No one may take possession of it.</p>
									</div>
									<div class="clear"> </div>                
                                </div>
                                <!-- headings div -->
                                <div id="picture">
                                    <div id="inpicture">
                                        <!-- background image -->
                                    </div>
                                    <!-- inpicture div -->
                                </div>
                                <!-- picture div -->
                                <div style="clear:both;">
                                </div>
                                <div id="main_navigation" class="wp-nav-menu-wrapper "><ul id="menu-main" class="menu"><li id="menu-item-928" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home cis-level-0 menu-item-928"><a href="https://blog.blackbam.at/">Overview</a></li>
<li id="menu-item-929" class="menu-item menu-item-type-post_type menu-item-object-page cis-level-0 menu-item-929"><a href="https://blog.blackbam.at/blackbams-links/">Linklist</a></li>
<li id="menu-item-930" class="menu-item menu-item-type-post_type menu-item-object-page cis-level-0 menu-item-930"><a href="https://blog.blackbam.at/developer-news/">Developer News</a></li>
<li id="menu-item-932" class="menu-item menu-item-type-custom menu-item-object-custom cis-level-0 menu-item-932"><a href="https://blog.blackbam.at/2010/10/25/core-theme/">WP Core Theme</a></li>
<li id="menu-item-931" class="menu-item menu-item-type-post_type menu-item-object-page cis-level-0 menu-item-931"><a href="https://blog.blackbam.at/impressum/">About this blog</a></li>
</ul></div>                                
                                <div id="menu_mobile" class="mobile-only">
                                    <div id="menu_mobile_bar"></div>
                                    <div id="menu_mobile_inner">
                                        <div class="menu_mobile_closer"></div>
                                            <div id="menu_mobile_actual" class="wp-nav-menu-wrapper "><ul id="menu-main-1" class="menu"><li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home cis-level-0 menu-item-928"><a href="https://blog.blackbam.at/">Overview</a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page cis-level-0 menu-item-929"><a href="https://blog.blackbam.at/blackbams-links/">Linklist</a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page cis-level-0 menu-item-930"><a href="https://blog.blackbam.at/developer-news/">Developer News</a></li>
<li class="menu-item menu-item-type-custom menu-item-object-custom cis-level-0 menu-item-932"><a href="https://blog.blackbam.at/2010/10/25/core-theme/">WP Core Theme</a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page cis-level-0 menu-item-931"><a href="https://blog.blackbam.at/impressum/">About this blog</a></li>
</ul></div>                                    </div>
                                </div>
                                
                                
                                
                            </div>
                            <!-- head div -->
                            <div style="clear:both;">
                            </div>
                            <div id="mainpart">
                                <!-- Ende des Kopfbereichs -->

<div id="single_article">


<div id="single_nav">
			<div class="lfloat">&laquo; <a href="https://blog.blackbam.at/2011/06/12/remove-the-wordpress-iis-404-page-problem-by-hack/" rel="next">Remove the WordPress IIS 404 page problem by hack</a></div>
			<div class="rfloat"><a href="https://blog.blackbam.at/2011/05/15/get-the-wordpress-excerpt-by-specifying-a-maximum-amount-of-characters/" rel="prev">Get the WordPress-excerpt by specifying a maximum amount of characters</a> &raquo;</div>
</div><!-- single_nav div -->
<div style="clear:both;"></div>
<div id="single_bord1"></div>

	<div id="post-1424">
			<div class="wp_article_head">
         	  <div class="date_auth">
          		 <div class="date">
           		  9. June 2011          	     </div><!-- date div -->
            	 <div class="author">
            	 von Blackbam           	     </div><!-- author div -->
             </div><!-- date_auth div -->
             <div class="art_head">
               <h1>|| <a href="https://blog.blackbam.at/2011/06/09/wordpress-custom-external-authentication-loginlogout-php-script/" rel="bookmark" title="Permalink: WordPress custom external authentication login/logout PHP script">WordPress custom external authentication login/logout PHP script</a></h1>
            </div><!-- art_head div -->
            </div><!-- wp_article_head div -->
           <div class="art_seperator">
           </div> <!-- art_seperator div -->
           <div class="art_content">
           		<p>Recently I was confronted with the problem to have multiple user types on a WordPress Blog who needed to be logged in using an external service/authentication mechanism partly. But they all had to use the same login form for the system. A common problem? The WordPress Function Reference and  Codex do not document this topic very well and it took me a lot of time to figure out how to do this best, so I want to keep it for the future and provide it to my blog visitors.</p>
<p>&nbsp;</p>
<h3>Override the WordPress default login action</h3>
<p>&nbsp;</p>
<p>Write the following to your functions.php-file:</p>
<pre lang="php">// this action is executed just before the invocation of the WordPress authentication process
add_action('wp_authenticate','checkTheUserAuthentication');

function checkTheUserAuthentication() {

     $username=$_POST['log'];
     $password=$_POST['pwd'];

    // try to log into the external service or database with username and password
    $ext_auth = try2AuthenticateExternalService($username,$password);

    // if external authentication was successful
    if($ext_auth) {

         // find a way to get the user id
         $user_id = username_exists($username);
         // userdata will contain all information about the user
         $userdata = get_userdata($user_id);
         $user = set_current_user($user_id,$username);

         // this will actually make the user authenticated as soon as the cookie is in the browser
         wp_set_auth_cookie($user_id);
         // the wp_login action is used by a lot of plugins, just decide if you need it
        do_action('wp_login',$userdata->ID);

        // you can redirect the authenticated user to the "logged-in-page", define('MY_PROFILE_PAGE',1); f.e. first
        header("Location:".get_page_link(MY_PROFILE_PAGE));
    }

}</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Note that this script will login your useres totally <strong>without using their passwords</strong>, so use it carefully.</p>
<p>&nbsp;</p>
<p>If you experience any problems with this way of authentication, make sure that the Cookies in the Browser are set and sent properly &#8211; make sure that setcookie() in wp-includes/pluggable.php uses all parameters of the setcookie()-function correctly. Especially check the values for COOKIE_DOMAIN, COOKIEPATH and SITECOOKIEPATH as we had and issue with that.</p>
<p>&nbsp;</p>
<div class="addtoany_share_save_container addtoany_content addtoany_content_bottom"><div class="a2a_kit a2a_kit_size_32 addtoany_list" data-a2a-url="https://blog.blackbam.at/2011/06/09/wordpress-custom-external-authentication-loginlogout-php-script/" data-a2a-title="WordPress custom external authentication login/logout PHP script"><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share"><img src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></div></div>            </div><!-- art_content div -->
                
                
			<div id="single_zusatz">
				<p>
				
												Dieser Eintrag wurde am 9. June 2011 um 22:22 in der Kategorie <a href="https://blog.blackbam.at/category/web-development/wordpress/" rel="category tag">WordPress</a>, <a href="https://blog.blackbam.at/category/web-development/wordpress/scripts-wordpress/" rel="category tag">WP Scripts</a> ver&ouml;ffentlicht.						You can book the comments for this article <a href='https://blog.blackbam.at/2011/06/09/wordpress-custom-external-authentication-loginlogout-php-script/feed/'>RSS 2.0</a>. 
													Feedback, discussion, commendation and critics are welcome: <a href=\"#respond\">Write a comment</a> or <a href=\"https://blog.blackbam.at/2011/06/09/wordpress-custom-external-authentication-loginlogout-php-script/trackback/\" rel=\"trackback\">trackback</a>.
						                    
                                       <!-- pruefen ob externe links zu dem Thema existieren und sie ausgeben, benoetigt ext_related_links plugin -->
                    
                    
                   </p>
               <br/><p>Tags: <a href="https://blog.blackbam.at/tag/authentication/" rel="tag">authentication</a>, <a href="https://blog.blackbam.at/tag/custom-script/" rel="tag">custom script</a>, <a href="https://blog.blackbam.at/tag/login/" rel="tag">login</a>, <a href="https://blog.blackbam.at/tag/logout/" rel="tag">logout</a>, <a href="https://blog.blackbam.at/tag/wp_authenticate/" rel="tag">wp_authenticate</a>, <a href="https://blog.blackbam.at/tag/wp_login/" rel="tag">wp_login</a>, <a href="https://blog.blackbam.at/tag/wp_signon/" rel="tag">wp_signon</a></p>  
   		   </div> <!-- single_zusatz div -->		   		   	</div> <!-- single_article div -->

    	

<div id="comments">
<h3 id="cmt_head">Already 27 comments belonging to "WordPress custom external authentication login/logout PHP script": </h3>
<p id="cmt_und"><a href="https://blog.blackbam.at/2011/06/09/wordpress-custom-external-authentication-loginlogout-php-script/feed/">Kommentare abonnieren (RSS)</a> or <a href="https://blog.blackbam.at/2011/06/09/wordpress-custom-external-authentication-loginlogout-php-script/trackback/">URL Trackback</a></p>



Warning: Undefined variable $comment_id in /home/.sites/609/site1266/web/blackbams-blog/wp-content/themes/SilentWoodsByBlackbam/comments.php on line 32



<div id="comment-205" class="kommentar">
	
	<div class="gravatar">
		<img alt='' src='https://secure.gravatar.com/avatar/eead77974094fb9ef8bb5d3c346489dd6c15f33d9e7063351931d25a696ab83c?s=48&#038;d=mm&#038;r=r' srcset='https://secure.gravatar.com/avatar/eead77974094fb9ef8bb5d3c346489dd6c15f33d9e7063351931d25a696ab83c?s=96&#038;d=mm&#038;r=r 2x' class='avatar avatar-48 photo' height='48' width='48' decoding='async'/>	</div>
	
	<div class="outer_comment_box">
		<div class="comment_box">
		<h4> <a href="mailto:info@cedricve.me">Cedric</a><a href="mailto:info@cedricve.me">&#160;<img src="https://blog.blackbam.at/wp-content/themes/SilentWoodsByBlackbam/images/mail.jpg" width="11" height="12" alt="" /></a> <a href="http://www.cedricve.me">&#160;<img src="
Fatal error: Uncaught Error: Undefined constant "template_url" in /home/.sites/609/site1266/web/blackbams-blog/wp-content/themes/SilentWoodsByBlackbam/comments.php:56
Stack trace:
#0 /home/.sites/609/site1266/web/blackbams-blog/wp-includes/comment-template.php(1629): require()
#1 /home/.sites/609/site1266/web/blackbams-blog/wp-content/themes/SilentWoodsByBlackbam/single.php(90): comments_template()
#2 /home/.sites/609/site1266/web/blackbams-blog/wp-includes/template-loader.php(106): include('/home/.sites/60...')
#3 /home/.sites/609/site1266/web/blackbams-blog/wp-blog-header.php(19): require_once('/home/.sites/60...')
#4 /home/.sites/609/site1266/web/blackbams-blog/index.php(17): require('/home/.sites/60...')
#5 {main}
  thrown in /home/.sites/609/site1266/web/blackbams-blog/wp-content/themes/SilentWoodsByBlackbam/comments.php on line 56
<error>
    <code>internal_server_error</code>
    <title><![CDATA[WordPress &amp;rsaquo; Error]]></title>
    <message><![CDATA[&lt;p&gt;There has been a critical error on this website.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://wordpress.org/documentation/article/faq-troubleshooting/&quot;&gt;Learn more about troubleshooting WordPress.&lt;/a&gt;&lt;/p&gt;]]></message>
    <data>
        <status>500</status>
    </data>
</error>
