Can set_transient() be used in multi-site?

As the Codex suggests: Essentially the same as set_transient() but works network wide when using WP Multisite. One difference is that the transient name should be 40 characters or less in length. Also, while set_transient() sets transients that have an expiration time to not autoload, all transients added with set_site_transient will auto-load at all times. … Read more

How to add class in plugin only for network site?

How are you invoking ngob_sitelist_slug? I’m gonna guess that you are doing something like $my_class = new ngob_sitelist_slug;. Doing it this way would require that your class have a constructor. if it doesn’t, you’ll get an error. You could still call your class methods statically: $my_thing = ngob_sitelist_slug::my_method(); Though technically you should add the static … Read more

Use another author.php if different multisite subsite?

This was the solution.. // different author template */ add_filter( ‘template_include’, ‘author_template’, 99 ); function author_template( $template ) { if( !is_main_site() and is_author( ) ) { $new_template = locate_template( array( ‘other-author.php’ ) ); if ( ” != $new_template ) { return $new_template ; } } return $template; }

WordPress Multisite/Network – How to use a subdomain as main blog and subdomain for child sites

There’s a couple of different ways that might work, but both rely on using Apache/NGINX directives. Method 1 Setup WordPress MS at mydomain.com, create an admin.mydomain.com site and then redirect mydomain.com to admin.mydomain.com. All additional sites would naturally be subdomains to mydomain.com. Method 2 This is basically the inverse of Method 1. You should be … Read more

Avoid having infinite loops

Yes it will give you infinite loop, because you’re calling the WP_User::set_role method within the set_user_role action that’s again fired within the the WP_User::set_role method. Not sure what the setup is but you can try to run it only once, with remove_action( current_action(), __FUNCTION__ ); as the first line in your callback, or use another … Read more