How to get user ID’s from multiple usernames?

Your call to get_user_by() has a small hiccup in it. It needs to be login rather than user_login // Search these Usernames $usernames = array(‘user1’, ‘user2’); // Fetch the User IDs $prof_ids = array(); foreach ($usernames as $prof_id) { $user = get_user_by(‘login’, $prof_id); $prof_ids[] = $user->ID; } // WP_User_Query arguments $args = array( ‘include’ => … Read more

If Array Values Match Another Array’s Values, Then

Here’s one way to solve this: sort both arrays loop through them and compare them item by item (they should be equal, because arrays are sorted) . sort( $evaltypesReq ); sort( $evaltypesSch ); $containsAllValues = true; foreach ( $evaltypesReq as $k => $v ) { if ( $evaltypesSch[$k] !== $v ) $containsAllValues = false; }

How to access or parse key/values that have “string”

In it’s current state you would directly get the value from the associative PHP array by directly referencing the key like so: var_dump( $form_data[‘key’] ); It’s wise to note that when you dump variables using var_dump you get information on the value type, and length. So in this case you get string(33) which indicates the … Read more

Link To Child Category For A Post

You can use get_category_link() for that: $allCat = get_the_category(); if( ! empty( $allCat ) ){ $lastCat = array_reverse( $allCat ); $last_cat_link = get_category_link( $lastCat[0] ); if( ! is_wp_error( $last_cat_link ) ){ echo ‘<a href=”‘ . $last_cat_link . ‘”>’ . $lastCat[0]->name . ‘</a>’; } } https://developer.wordpress.org/reference/functions/get_category_link/

Obtaining array item from WordPress revisions output

To get the post author ID you can try: $revisions = wp_get_post_revisions($post->ID); //For first author $first_author = $revisions[0]->post_author; //to get all revision authors foreach( $revisions as $revision ){ echo $revision->post_author; }

Loop over Array and get the distinct ids

No, that’s because you are treating an array as an object and PHP doesn’t convert those types automatically. To get an individual element from an object you use: $my_object->Element1; To get an individual element from an array you use: $my_array[Element1]; You can even nest arrays. So if you have $my_array, where each element is another … Read more

get_users with array as meta_value

First, can use meta_query, but, you should change your values to use the proper date format, e.g. 2020/01/02 for January 2nd, rather than a regional format. See https://en.wikipedia.org/wiki/ISO_8601 for more details. Second, your LIKE query is going to be very expensive, and achieving what you want while still using a LIKE query will be even … Read more

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