{"id":23,"date":"2007-05-25T07:35:56","date_gmt":"2007-05-25T14:35:56","guid":{"rendered":"http:\/\/blogs.elsweb.org\/jimgroom\/wpmu-permissions-hack-for-new-users\/"},"modified":"2007-05-25T07:35:56","modified_gmt":"2007-05-25T14:35:56","slug":"wpmu-permissions-hack-for-new-users","status":"publish","type":"post","link":"https:\/\/blogs.elsweb.org\/jimgroom\/wpmu-permissions-hack-for-new-users\/","title":{"rendered":"WPMU permissions hack for new users"},"content":{"rendered":"<p> If you are using or administrating WordPress Multi-User you may have come across the following error message for new users creating just a login name (not getting  blog):<\/p>\n<blockquote>\n<p>You do not have sufficient permissions to access this page.<\/p>\n<\/blockquote>\n<p>This problem can get pretty frustrating if you are using a single blog on WPMU that has several users.  For example, I created one blog for my class this Summer that has six additional users.  Each of the students created a login name without a problem, but when they tried to sign on to the site (and I had given them all editing permissions) they received the above message. This can be worked around clunkily with a couple of hard refreshes and a handy edit button on a post, but there is a better hack.<\/p>\n<p>On the WPMU forums I found the following <a href=\"http:\/\/mu.wordpress.org\/forums\/topic.php?id=2424#post-17830\">solution<\/a>. According to this thread, and others like it, this is a more general issue with WPMU 1.0 and hasn&#8217;t really been addressed as of yet.  However, as is often the case with open source applications, someone has come up with a quick hack that has worked perfectly for me thus far.  Below is the code for the plugin to make this problem go away.<br \/>\n<code>&lt;?php<br \/>\n\/*<br \/>\nPlugin Name: ADRX No Caps User Login<br \/>\nPlugin URI:<br \/>\nDescription: This plugin determines what happens when a user logins in at a blog for which s\/he has no capabilites.<br \/>\n*\/<br \/>\nfunction adrx_nocaps_login() {<br \/>\nglobal $current_site, $current_blog, $current_user, $user_ID, $wpdb;<br \/>\nif (!is_blog_user() || !is_site_admin) { \/\/ no caps and not site admin<br \/>\nif ($current_blog-&gt;domain==$current_site-&gt;domain) { \/\/ logged in at main site &#8212; no caps<br \/>\n\/\/ if user has blog, send user there - code copied from menu.php<br \/>\n$primary_blog = $wpdb-&gt;get_var( &#8220;SELECT meta_value FROM {$wpdb-&gt;usermeta} WHERE user_id = &#8216;$user_ID&#8217; AND meta_key = &#8216;primary_blog&#8217;&#8221; );<br \/>\nif( $primary_blog ) {<br \/>\n$newblog = $wpdb-&gt;get_row( &#8220;SELECT * FROM {$wpdb-&gt;blogs} WHERE blog_id = &#8216;{$primary_blog}&#8217;&#8221; );<br \/>\nif( $newblog != null ) {<br \/>\nheader( &#8220;Location: http:\/\/&#8221; . $newblog-&gt;domain . $newblog-&gt;path . &#8220;wp-admin\/&#8221; );<br \/>\nexit;<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\n\/\/ user has no caps here<br \/>\n\/\/ user either has no existing primary blog of his\/her own or did not log in at main site<br \/>\n\/\/ redirect to front page of the blog at which s\/he logged in<br \/>\nheader( &#8220;Location: http:\/\/&#8221; . $current_blog-&gt;domain. &#8220;\/&#8221; );<br \/>\nexit;<br \/>\n}<br \/>\n}<br \/>\nadd_action(&#8217;admin_menu&#8217;, &#8216;adrx_nocaps_login&#8217;);<br \/>\n?&gt;<\/code><\/p>\n<p>Just copy the above code into a text editor, save it as adrx.php, and copy it into the mu-plugins folder of your WPMU install.  That&#8217;s it!  Hopefully this will be solved in the next version, for it is a pretty big problem if you are going to have a multi-user blog within this environment.<\/p>\n<p class=\"akst_link\"><a href=\"http:\/\/bavatuesdays.com\/?p=456&amp;akst_action=share-this\" title=\"E-mail this, post to del.icio.us, etc.\" id=\"akst_link_456\" class=\"akst_share_link\">Share This<\/a>\n<\/p>\n<p>Original post by <em><a href=\"http:\/\/bavatuesdays.com\/wpmu-permissions-hack-for-new-users\/\" title=\"\">jimgroom<\/a><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are using or administrating WordPress Multi-User you may have come across the following error message for new users creating just a login name (not getting blog): You do not have sufficient permissions to access this page. This problem can get pretty frustrating if you are using a single blog on WPMU that has [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-23","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.elsweb.org\/jimgroom\/wp-json\/wp\/v2\/posts\/23","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.elsweb.org\/jimgroom\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.elsweb.org\/jimgroom\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.elsweb.org\/jimgroom\/wp-json\/wp\/v2\/comments?post=23"}],"version-history":[{"count":0,"href":"https:\/\/blogs.elsweb.org\/jimgroom\/wp-json\/wp\/v2\/posts\/23\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.elsweb.org\/jimgroom\/wp-json\/wp\/v2\/media?parent=23"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.elsweb.org\/jimgroom\/wp-json\/wp\/v2\/categories?post=23"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.elsweb.org\/jimgroom\/wp-json\/wp\/v2\/tags?post=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}