{"id":11034310,"date":"2018-12-29T00:49:43","date_gmt":"2018-12-29T00:49:43","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/code-to-display-different-logon-pages-to-users\/"},"modified":"2018-12-29T00:49:43","modified_gmt":"2018-12-29T00:49:43","slug":"code-to-display-different-logon-pages-to-users","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/code-to-display-different-logon-pages-to-users\/","title":{"rendered":"Code to display different logon pages to users"},"content":{"rendered":"<p>I have created the snippet below and it doesn&#8217;t seem to work. Am I missing something important about how snippets work? For example, when i log in as the user &#8216;fred&#8217; the behaviour does not change if the snippet is active or not.<br \/>\n`\/**<br \/>\n * When a user is logged in, tell WordPress to use &#8216;page&#8217; on front page of the site<br \/>\n * @param string $value<br \/>\n *<br \/>\n * @return string<br \/>\n *\/<br \/>\nadd_filter( &#8216;pre_option_show_on_front&#8217;, function(){<br \/>\n\tif (!is_user_logged_in()) {return;}<br \/>\n    if ( is_user_logged_in() )<br \/>\n      {<br \/>\n        global $wpdb;<br \/>\n        $tbl=$wpdb-&gt;prefix.&#8221;posts&#8221;;<br \/>\n        $current_user = wp_get_current_user();<br \/>\n\t\tswitch ($current_user-&gt;user_login)<br \/>\n          {<br \/>\n            case &#8216;fred&#8217;:$page=&#8217;mbc_crm_all_functions&#8217;;break;<br \/>\n            case &#8216;faae&#8217;:$page=&#8217;mbc_crm_all_functions&#8217;;break;<br \/>\n            case &#8216;bob&#8217;:$page=&#8217;mbc_menu_all_functions&#8217;;break;<br \/>\n\t\t\tdefault: $page=&#8221;&#8221;;<br \/>\n          }<br \/>\n\t\tif ($page&lt;&gt;&#8221;&#8221;)<br \/>\n\t\t  {<\/p>\n<p>            $sql=&#8221;select ID from $tbl where post_type=&#8217;page&#8217; and post_name='&#8221;.&#8221;$page'&#8221;;<br \/>\n            $value=intval($wpdb-&gt;get_var($sql)); \/\/set page ID<br \/>\n          }<br \/>\n\t  }<br \/>\n    return $value;<br \/>\n});<\/p>\n","protected":false},"template":"","class_list":["post-11034310","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/11034310","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/11034310\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=11034310"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}