Assign random (and unique) user meta upon registration

You can use the hook user_register to modify user data upon registration. You can use the function add_user_meta to add custom data to a user. Example: add_action(‘user_register’, ‘add_pin_number’, 10, 1); function add_pin_number($user_id) { add_user_meta( $user_id, ‘pin_number’, $random_number , true ); } You can look for php function out there to help you creating the random … Read more

Hide comments and posts posted by other user

You can use a filter to pre_get_posts so that only your posts are listed. Something like this: function my_posts_only( $query ) { global $pagenow; if ( ‘edit.php’ != $pagenow || ! $query->is_admin ) return $query; if ( ! current_user_can( ‘manage_options’ ) ) { global $user_ID; $query->set( ‘author’, $user_ID ); } return $query; } add_filter( ‘pre_get_posts’, … Read more

Send email to all registered users [closed]

Before you begin, you should know that sending mass emails is a delicate subject matter, and your hosting provider or mail provider has certain guidelines about this. Some hosting providers, such as Dreamhost, provide “Announcement Lists”, which act as a platform for writing newsletters (or essentially emailing a large group of subscribers). Sending unsolicited email … Read more

Users – remove ‘send password’ checkbox

Here are few ideas how to deal with the neutralization of the Send Password part on the /wp-admin/user-new.php page: Idea 1: We can overwrite the wp_new_user_notification() function, because it’s pluggable: Try for example: if ( ! function_exists( ‘wp_new_user_notification’ ) ): function wp_new_user_notification($user_id, $plaintext_pass=””) { $user = get_userdata( $user_id ); // The blogname option is escaped … Read more

Add field to user meta table in database when link is clicked

Personally, I would store the post IDs (as opposed to URLs). Something like: function wpse_143643_add_user_bookmark() { if ( ! empty( $_GET[‘bookmark’] ) && is_singular() && is_user_logged_in() ) { if ( ! $bookmarks = get_user_meta( $user_id = get_current_user_id(), ‘bookmarks’, true ) ) $bookmarks = array(); $bookmarks[] = get_queried_object_id(); $bookmarks = array_unique( $bookmarks ); update_user_meta( $user_id, ‘bookmarks’, … Read more

php if username is role

Chris Haugen, You need to check user role who have ‘artist’ role and then you need to act on some video loop stuff. Here’s the solution: $user = get_user_by(‘login’, $username ); if ( !empty( $user->roles ) && is_array( $user->roles ) ) { foreach ( $user->roles as $role ){ if($role == ‘artist’) media files loop } … Read more