sontru
Forum Replies Created
-
Forum: Networking WordPress
In reply to: WP 3.5 – Don't I need to create blogs.dir?Thanks for the info Nelson.
I assume that the upgrade process to 3.5 will do this automatically (i.e. move all uploads from blogs.dir/* to the appropriate blogs/{blog_id}?)
Forum: Networking WordPress
In reply to: creating a multisite installation – 1st time…I had this ‘remove the network database tables’ even with a fresh install. Check the permissions of your file in the WordPress directory.
I fixed this issue by making all the files owned by the user (and group) Apache runs under (www-data).
Forum: Networking WordPress
In reply to: FirstTime Multi-Siter has a formatting question!Each new site that is created takes the default theme. You can set the default theme in the wp-config.php file, using:
define('WP_DEFAULT_THEME', theme_name);
With regards to plugins – you can ‘Network Activate’ plugins which will activate them on all sites.
Forum: Networking WordPress
In reply to: Create local users in each subdomainI don’t know what version of WordPress Multisite you are using, but for me with 3.4.2, network users are not members of any subdomain unless you make them so (either manually or using a plugin).
I am currently writing a plugin to replace the add new user page but this is taking me a while. In the meantime I have modified the wpmu_signup_user function as detailed above (to add the domain suffix).
Forum: Networking WordPress
In reply to: How do I replace the 'Add New User' admin page?Thanks guys,
I’ve solved it with the following
add_action( 'admin_menu', 'adjust_the_wp_menu'); function adjust_the_wp_menu() { $page = remove_submenu_page( 'users.php', 'user-new.php' ); add_users_page('My Users', 'Add New', 'administrator', __FILE__, 'my_user_page'); } function my_user_page(){ echo "HELLO"; }
(I don’t know why my page appears as the bottom in the submenu list – is there a way of ordering the submenu items? I want my page menu item to be in the same position, 2, as the original Add New item.)
I will check out the Admin Menu Editor plugin if I get unstuck again.
Forum: Networking WordPress
In reply to: Account activation on 'Members Only' siteWorks like a treat! Thanks.
Forum: Networking WordPress
In reply to: Account activation on 'Members Only' siteCheers for the replies and info. I thought it might be as easy as just unblocking the activation page (a page exclude list in the plugin) somehow…
Forum: Networking WordPress
In reply to: Account activation on 'Members Only' siteSurely there must be away of allowing users to activate without blocking?
Forum: Networking WordPress
In reply to: Create local users in each subdomainThanks for the ideas, but I think I have it solved ?? You are right that I have a namespace clash – out of interest, if you use Shibboleth (assuming using the same plugin as everybody else) and also have local users – how do you resolve the namespace clash problem? (Say, what happens in your case, if you have a local user in your database – Bob, then comes along a user who logs in via Shibboleth authentication who’s login name is als Bob – what happens?)
My solution is (1) ‘local’ wp user who can login using Shib, (2) email login enabled, and (3) local wp users with domain suffix (who might be restricted only to the subdomain they were created for – depending if I can find the right user management plugin).
The locally created subdomain users do not have their login name changed – they are created by the admin who will be informed that the user they are creating has the suffix added to the login name (and the email that goes to the user will inform them that their login is bob_subdomain) no confusion there. Email login is enabled so users can use their email address to login (so so fuss there with remembering login names).
I have hacked the ms-functions.php so that it appends the suffix to users created in/for a subdomain – and this works. The remaining issue is how to write a plugin to do this so that whenever the WP MS code is changed, I do not need to constantly hack it again…
Ipstenu (Mika Epstein) and I have been trying to locate the hook that will allow me to write a plugin, and we have concluded that it is not as simple as we might expect. We think the plugin will need to replace the Create New User admin (in the subdomain) page, which might be a good thing because that would be where I inform them that they are creating local (to the subdomain user) whose login name will be suffixed with the name of their subdomain. (But who can login using their email address if they want to or can’t remember the strange login name.)
It will take some work to get a plugin to do the simple task of adding the subdomain suffix, so for the meantime I will leave the hack code in the ms-functions.php to do its work, and hope I don’t need to upgrade MS WP anytime soon…
Forum: Networking WordPress
In reply to: Create local users in each subdomainNo you are not too late – thanks for the interest.
OK, this is a short breakdown. I had to set up a WP MS system and integrate it with our SSO – Shibboleth. I have done this now, and it works. However, I have found that with MS, users are all global. We want local users (users created and maybe restricted to a specific subdomain) as well as global users (Shib). This is so ‘external’ users can be created and allow to login/contribute within the subdomains.
Now because users who login using Shib gets an account created automatically, what happens if a subdomain creates a user (login name) that is the same as the Shib user? (Note the two users are different people).
So this is the problem, which I think can be solved with this. Shib users login and get created as per plugin. User created in a subdomain gets the login name suffixed with the subdomain.
So Shib user ‘bob’ is different from user bob_subdomain1, different from bob_subdomain2.
I think one problem to understand is that we are allowing Admins of our subdomain the ability to create users. So they could create login names that could potentially clash with the ‘global’ Shib logins. Also, we can not guarantee that a subdomain user created today with a unique login name that does not clash with Shib user, will be the same user that get created in Shib tomorrow…
Forum: Networking WordPress
In reply to: Create local users in each subdomainYes, it may have to come down to this (although this sounds like a bigger project!)
How do I start going about replacing the ‘Add New User’ admin page in the subdomain only? Any pointers would be appreciated…
P.S. I think I just need to be able to call the function that inserts the user into the wpmu_signups table, which I think is wpmu_signup_user, but I don’t seem to be able to hook up there.
Forum: Networking WordPress
In reply to: Create local users in each subdomainThe reason I am not using wpmu_activate_user (initially suggested) is because of the validation/activation part.
There is a wp_signups table that maintains and reserves unique login names. If this table does not get updated with the login_subdomain then there will be problems with subdomains creating users, such as billy_domain1 and billy_domain2. These login named will be treated as the same if they don’t get suffixed before it goes into the wp_signups table.
I will verify this if I get the plugin to work with wpmu_create_user.
EDIT: I don’t think this would work. I used to have my code inserted directly into ‘function wpmu_activate_signup($key)’ at about //HERE!:
$user_id = username_exists($user_login); if ( ! $user_id ) { //HERE! $hostAddress = explode('.',$_SERVER['HTTP_HOST']); $user_login .= '_' . $hostAddress[0]; $user_id = wpmu_create_user($user_login, $password, $user_email); } else $user_already_exists = true; if ( ! $user_id ) return new WP_Error('create_user', __('Could not create user'), $signup);
i.e. before wpmu_create_user is called. Although this added the suffix to the $user_login, this username does not appear in the wp_signups table.
Forum: Networking WordPress
In reply to: Create local users in each subdomainIs that a no? What can I do instead? Is hacking ms-functions.php my only choice?
Forum: Networking WordPress
In reply to: Create local users in each subdomainNope. The code being:
function add_suffix_to_login($user, $user_email, $meta = '') { // $hostAddress = explode('.',$_SERVER['HTTP_HOST']); $user .= '_'; // . $hostAddress[0]; return $user; } add_action('wpmu_signup_user', 'add_suffix_to_login',10,3);
and no underscore is added. In fact, this code does not even work:
function add_suffix_to_login($user, $user_email, $meta = '') { // $hostAddress = explode('.',$_SERVER['HTTP_HOST']); // $user .= '-' . $hostAddress[0]; $user = 'testusersontru'; return $user; } add_action('wpmu_signup_user', 'add_suffix_to_login',10,3);
which means the function is not being called. I’m a newbie at this but is there a hook for this function ‘wpmu_signup_user’ for the action to be added?
Forum: Networking WordPress
In reply to: Create local users in each subdomainThanks for that. I thought I had already tried that and it did work. So I tried it again and… nope does not work for some reason. My code is in a plugin file which fixes the ‘login name must be a minimum of 4 characters’ error, and an email login code which works. (Included here in case anyone want these problems fixed too…)
<?php /* Plugin Name: Email Login, Remove Min 4 Chars Login Name, Add Subdomain Suffix Plugin URI: Description: Does all of the above! Author: sontru Version: 1.3.0 Author URI: */ function login_with_email_address($username) { $user = get_user_by_email($username); if(!empty($user->user_login)) $username = $user->user_login; return $username; } add_action('wp_authenticate','login_with_email_address'); function remove_username_char_limit($result) { if ( is_wp_error( $result[ 'errors' ] ) && !empty( $result[ 'errors' ]->errors ) ) { // Get all the error messages from $result $messages = $result['errors']->get_error_messages(); $i = 0; foreach ( $messages as $message ) { // Check if any message is the char limit message if ( 0 == strcasecmp("Username must be at least 4 characters.", $message)) { // Unset whole 'user_name' error array if only 1 message exists // and that message is the char limit error if ( 1 == count($messages) ) { unset( $result['errors']->errors['user_name'] ); } else { // Otherwise just unset the char limit message unset( $result['errors']->errors['user_name'][$i] ); } } $i++; } } return $result; } add_action('wpmu_validate_user_signup', 'remove_username_char_limit'); function add_suffix_to_login($user, $user_email, $meta = '') { $hostAddress = explode('.',$_SERVER['HTTP_HOST']); $user .= '_' . $hostAddress[0]; return $user; } add_action('wpmu_signup_user', 'add_suffix_to_login',10,3); ?>
<strike>Is there a different between a calling add_action before defining the function and after it?</strike> Just tried this and no difference – still does not have the desired effect.