Display site administrator’s id by current blog id inside link

If you want to construct for example: http://example.com/?ref=1,8,22 for multiple administrators of the current sub site, you can try the following (untested): $uids = get_users( array( ‘blog_id’ => get_current_blog_id(), ‘role’ => ‘administrator’, ‘fields’ => ‘ID’, ‘order_by’ => ‘ID’, ‘order’ => ‘ASC’, ) ); echo $url = add_query_arg( array( ‘ref’ => join( ‘,’, $uids ) ), … Read more

Generate unique number when registering a new user

This way would work … the user_register action is fired when the user is stored in the data base. You can add meta data to a user with add_metadata. add_action( ‘user_register’, ‘myplugin_registration_save’, 10, 1 ); function myplugin_registration_save( $user_id ) { add_metadata( $user_id, ‘unique_number’, date( ‘Y’ ).str_pad( $user_id, 4 ) ); }

Buddypress activity id

That function is called right in entry.php as follows: <li class=”<?php bp_activity_css_class(); ?>” id=”activity-<?php bp_activity_id(); ?>”> Note that bp_activity_id() will echo the value. To use the value in code, call bp_get_activity_id().

Getting current post ID in functions.php

I believe this should work in all cases – whether you are in the loop or not. (In a widget, chances are you are not in the loop) Mind you, outside the loop, this will work very well on single pages or posts, but might not display the post you want on other types of … Read more

Get widget Title from widget id

You can get the widget name from the widget id with this: <?php global $wp_registered_widgets; $id = ‘recent-comments-1’; // example if ( isset($wp_registered_widgets[$id][‘name’]) ) { echo $wp_registered_widgets[$id][‘name’]; } ?>

How to check the array of featured images IDs

This is solely a PHP question. But as birgire mentioned, you can use in_array(). So, change your code to this: $post_thumbnail_id = get_post_thumbnail_id(); if( in_array( $post_thumbnail_id, array(1, 2, 3 ) ) ) { echo ‘<span>Location</span>’; } The first argument is your value, the second one is the array you want to search in.

post_author for wp_insert_attachment

My question is, is there a way to add a post_author to the wp_insert_attachment? I could not find that in the documentation. I need the attachment to have the same author id as that of the post. Currently it takes the id of the the admin. Sometimes the codex or published docs don’t tell the … Read more

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