wp_set_object_terms not accepting variable array

Ok, so it turned out that my array was an array of strings somehow, which using var_dump (instead of print_r) revealed. Then I needed to convert my array to int values, which I did thus: $myissuearrayINT = array_map(‘intval’, $myissuearray); And now, when I do the following it works as expected: wp_set_object_terms( $myID, $myissuearrayINT, ‘my_issues’, true … Read more

How to set an array of current usernames

So right now you have this if ($user && isset($user->user_login) && ‘username’ == $user->user_login ) { To check for one specific user. If you want to check against multiple usernames, PHP’s function in_array() comes in handy $allowed = array( ‘user1’, ‘user2’, ); if ($user && isset($user->user_login) && in_array($user->user_login, $allowed) ) {

wp_update_post to set post IDs to drafts not working

Well in your for loop, I think you’re missing the $postcount variable… also there’s a typo at $idss[$i] …. should be $ids[i] based on what you’ve shown. for ($i = 0; $i < $postcount; $i++) { wp_update_post(array(‘ID’ => $ids[$i], ‘post_status’ => ‘draft’)); } That being said I’d just go with a foreach loop. The mistake … Read more

How to avoid duplicate users when I am using get_users?

I think it’s arguments issue. I recommend not to use role & role__not_in together rather either use only role OR use role__in & role__not_in combination. Also check your role param spelling. (see more on role) 2ndly orderby param rand is not valid according to codex (see here) so use proper param.

How to output get_tags array list to select box

You can do it like so — replace the $tags_array = get_tags(); with this: $tags_opt = array(); foreach ( get_tags() as $term ) { $tags_opt[] = array( ‘label’ => $term->name, ‘value’ => $term->term_id, ); } And then, for the “Select Box” field, set the options to $tags_opt like this: array( ‘label’ => ‘Select Box’, … … Read more

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