Code to display different logon pages to users
-
I have created the snippet below and it doesn’t seem to work. Am I missing something important about how snippets work? For example, when i log in as the user ‘fred’ the behaviour does not change if the snippet is active or not.
`/**
* When a user is logged in, tell WordPress to use ‘page’ on front page of the site
* @param string $value
*
* @return string
*/
add_filter( ‘pre_option_show_on_front’, function(){
if (!is_user_logged_in()) {return;}
if ( is_user_logged_in() )
{
global $wpdb;
$tbl=$wpdb->prefix.”posts”;
$current_user = wp_get_current_user();
switch ($current_user->user_login)
{
case ‘fred’:$page=’mbc_crm_all_functions’;break;
case ‘faae’:$page=’mbc_crm_all_functions’;break;
case ‘bob’:$page=’mbc_menu_all_functions’;break;
default: $page=””;
}
if ($page<>””)
{$sql=”select ID from $tbl where post_type=’page’ and post_name='”.”$page'”;
$value=intval($wpdb->get_var($sql)); //set page ID
}
}
return $value;
});
The topic ‘Code to display different logon pages to users’ is closed to new replies.