{"id":660,"date":"2012-03-09T15:34:19","date_gmt":"2012-03-09T14:34:19","guid":{"rendered":"http:\/\/www.k-braungardt.de\/blogkb\/?p=660"},"modified":"2019-05-30T15:22:32","modified_gmt":"2019-05-30T14:22:32","slug":"subblog-registrations-on-wordpress-3-3-1","status":"publish","type":"post","link":"https:\/\/www.k-braungardt.de\/blogkb\/?p=660","title":{"rendered":"Subblog Registrations on WordPress 3.3.1"},"content":{"rendered":"<p>On WordPress Multisite it is not possible per default for users to register for sub-blogs. You are automatically redirected to the main blog.<\/p>\n<p>This is how you can solve the problem in wp-login.php:<\/p>\n<p>Sub Blog Setting is &#8222;Users can Register&#8220;: 1<\/p>\n<p>Changes in wp-login.php:<\/p>\n<p>1) In the Main part in case &#8218;register&#8216; two lines should be commented out: wp_direct and<br \/>\nexit. These are the lines responsible for redirecting to wp-sign-up with the Main Blog.<br \/>\nIf the redirect does not take place, users can register with the Sub Blog.<\/p>\n<p>case &#8218;register&#8216; :<br \/>\n\/\/ Multisite uses wp-signup.php<br \/>\n\t\t\/\/wp_redirect( apply_filters( &#8218;wp_signup_location&#8216;, site_url(&#8218;wp-signup.php&#8216;) ) );<br \/>\n\t\t\/\/exit;<\/p>\n<p>With these changes users can register only once for one Sub Blog. For another Sub Blog<br \/>\nthey would have to log in with a new account. To allow students to register with multiple<br \/>\nSub Blogs further changes have to be made in wp-login.php.<\/p>\n<p>2) For multiple Sub Blog Registration the function &#8222;register_new_user&#8220; is supplemented<br \/>\nby the following request: If a user is already registered username and email both have to<br \/>\nbe existent. If they both exist, the user is added as a subscriber to the blog:<br \/>\nFollowing the line: $user_email = apply_filters( &#8218;user_registration_email&#8216;, $user_email );<br \/>\nthese lines are added:<\/p>\n<p>if( username_exists( $sanitized_user_login ) &#038;&#038; email_exists( $user_email ) )<br \/>\n{<\/p>\n<p>$userid = username_exists($sanitized_user_login);<br \/>\n$blogid = $GLOBALS[&#8218;current_site&#8216;]->site_id;<br \/>\nadd_user_to_blog($blogid, $userid, &#8222;subscriber&#8220;);<br \/>\n}<br \/>\nelse<br \/>\n{<\/p>\n<p>The closing bracket is placed before return $user_id;<\/p>\n<p>3. What does the user get? The user goes to register for the Sub Blog and fills in his or her<br \/>\nusername and email adress. With first time registering a password is sent to the person&#8217;s<br \/>\nemail adress. If already registered, there is no password sent. So it would be nice to read<br \/>\nthis somewhere on the screen too.<br \/>\nIn the Main part in case &#8218;register&#8216; following the line <?php do_action('register_form'); ?><br \/>\nthe message can be changed to: A password will be e-mailed to you, if you register for the<br \/>\nfirst time.<\/p>\n<p>4. Users are registered with default role as subscriber. Roles can be easily changed in the<br \/>\nBlog Settings.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On WordPress Multisite it is not possible per default for users to register for sub-blogs. You are automatically redirected to the main blog. This is&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/www.k-braungardt.de\/blogkb\/?p=660\">Weiterlesen<span class=\"screen-reader-text\">Subblog Registrations on WordPress 3.3.1<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[86],"tags":[73,231,232,343],"class_list":["post-660","post","type-post","status-publish","format-standard","hentry","category-wordpress","tag-blog","tag-multisite","tag-register-subblog","tag-wordpress","entry"],"_links":{"self":[{"href":"https:\/\/www.k-braungardt.de\/blogkb\/index.php?rest_route=\/wp\/v2\/posts\/660","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.k-braungardt.de\/blogkb\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.k-braungardt.de\/blogkb\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.k-braungardt.de\/blogkb\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.k-braungardt.de\/blogkb\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=660"}],"version-history":[{"count":7,"href":"https:\/\/www.k-braungardt.de\/blogkb\/index.php?rest_route=\/wp\/v2\/posts\/660\/revisions"}],"predecessor-version":[{"id":667,"href":"https:\/\/www.k-braungardt.de\/blogkb\/index.php?rest_route=\/wp\/v2\/posts\/660\/revisions\/667"}],"wp:attachment":[{"href":"https:\/\/www.k-braungardt.de\/blogkb\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=660"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.k-braungardt.de\/blogkb\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=660"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.k-braungardt.de\/blogkb\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=660"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}