Long have I struggled with WordPress Multisite and the way it makes things difficult for non-super admin users. While it is very easy to join additional sites, leaving them on your own is easier said than done. I hesitate to write ‘impossible’ even now as it seems insane that there isn’t a good and obvious way for non-site admins to leave a site. Maybe someone will point out something obvious I’ve missed but in case I am right here is a way to allow users to control which sites show up in their My Sites list. After some thought, I went with the least dramatic path here. We are just removing the sites from the main views rather than deleting accounts on individual blogs. I started to go that route (remove_user_from_blog) but a conversation with Matt and the concerns about transferring ownership of the content or deleting the content and being able to un-do that if a mistake was made quickly made me think of some other options. I opted to use add a filter to the get_blogs_of_user function which builds both the drop down menu of sites and the blogs listed on the My Sites page. With the function below I can pass in an array of blog IDs to ignore when building the ‘My Sites’ list. You’ll also […]
I made a filter a while back to keep people who were associated with blogs through the bbpress/buddypress auto-enrollment feature from having tons of sites show up in their My Sites list. It was never a perfect solution and felt sloppy because it relied on having only one role and that role being bbp_participant. It also failed when I un-network activated bbPress because it couldn’t filter people who had no role (and there was still some invisible connection). And the final nail was that it seemed to fail intermittently and I had no idea why. Here is a very different path to the same result but one that appears to work better and will be proof against the ‘no role’ issue that hampered me earlier. It’s all made possible by the delightful array_interesect function. It’s one of those things that I am confident I’ll use down the road. I have no idea if it’s as commonly known as ABC or whatever but I had no idea it existed. This actually came to fruition on a plane trip because Mark Luetke told me about Varying Vagrant Vagrants and I was able to spend about twenty minutes working on this even without Internet. It has also made me reflect that lack of interruptions really improves my productivity on things like this.