How can I link users across multiple subdomains?

The fact that you haven’t mentioned MultiSite in your post makes me think that doing some research there would be a good next step for you: https://codex.wordpress.org/Create_A_Network User Accounts are shared across sites in the network, and sites can be different subdomains.

How can I default to all WordPress roles when parameter is not included in shortcode?

Try this: function profile_counts($atts) { $atts = shortcode_atts( array( ‘metakey’ => ”, ‘metavalue’ => ”, ‘userrole’ => ”, ), $atts ); $user_ids = get_users( array( ‘meta_key’ => $atts[‘metakey’], ‘meta_value’ => $atts[‘metavalue’], ‘role__in’ => wp_parse_list( $atts[‘userrole’] ), ‘fields’ => ‘ID’, // retrieve just the IDs ‘count_total’ => false, // no need for FOUND_ROWS() ) ); return … Read more

Set user loggin status?

Use wp_signon(). Ex: $creds = array(); $creds[‘user_login’] = ‘example’; $creds[‘user_password’] = ‘plaintextpw’; $creds[‘remember’] = true; $user = wp_signon( $creds, false ); if ( is_wp_error($user) ) echo $user->get_error_message(); See Codex for more details about wp_signon().

How can I get multisite primary blog (url or path) for current user?

Indeed, get_active_blog_for_user should work. $blog = get_active_blog_for_user( get_current_user_id() ); $blog_url = $blog->domain… /* or $blog->path, together with $blog->siteurl */ Alternatively: $blog_id = get_active_blog_for_user( get_current_user_id() )->blog_id; // note: changed “->userblog_id” to “->blog_id” in row above to make it work. switch_to_blog( $blog_id ); /* switch context */ $home_url = home_url(); restore_current_blog(); /* back */

Can I pass two roles to the function get_users?

I don’t think it’s possible to do it with the get_users function. From what the Codex implies, you cannot pass arrays to the role argument. But it should be fairly easy to code your way out of that limitation. Try this: function filter_two_roles($user) { $roles = array(‘academic’,’student’); return in_array($user->roles[0], $roles); } $users = get_users(‘fields=all_with_meta’); // … Read more

Creating a Front-end based User Search

As you haven’t offered the details on what you’re after, I’ll try to grab them all very briefly. Use the API – public WP_User_Query API functions Basically get_user_by() should be enough for you. Let’s say you fire of your form and the input field name was user_id. So you’d just retrieve the value from the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)