Get custom post count in custom taxonomy

To get total custom post count of a custom taxonomy use the follow code

$args = array(
    'post_type' => 'post type name here',
    'post_status' => 'published',
    'taxonomy name here' => 'slug of the category under taxonomy',
    'numberposts' => -1
);
echo $num = count( get_posts( $args ) );

For instance, if you had a custom taxonomy called “product_category” and wanted to only show posts from the “manes” product_category you would use the below code.

$args = array(
    'post_type' => 'product',
    'post_status' => 'published',
    'product_category' => 'manes',
    'numberposts' => -1
);
echo $num = count( get_posts( $args ) );

Set a maximum upload count for users on a specific user role

Use the following code to limit 10 upload for specific role

add_filter( 'wp_handle_upload_prefilter', 'limit_uploads_for_user_roles' );

function limit_uploads_for_user_roles( $file ) {
  $user = wp_get_current_user();
  // add the role you want to limit in the array
  $limit_roles = array('contributor');
  $filtered = apply_filters( 'limit_uploads_for_roles', $limit_roles, $user );
  if ( array_intersect( $limit_roles, $user->roles ) ) {
    $upload_count = get_user_meta( $user->ID, 'upload_count', true ) ? : 0;
    $limit = apply_filters( 'limit_uploads_for_user_roles_limit', 10, $user, $upload_count, $file );
    if ( ( $upload_count + 1 ) > $limit ) {
      $file['error'] = __('Upload limit has been reached for this account!', 'yourtxtdomain');
    } else {
      update_user_meta( $user->ID, 'upload_count', $upload_count + 1 );
    }
  }
  return $file;
}

This action will fire when user delete attachment

add_action('delete_attachment', 'decrease_limit_uploads_for_user');

function decrease_limit_uploads_for_user( $id ) {
   $user = wp_get_current_user();
   // add the role you want to limit in the array
   $limit_roles = array('contributor');
   $filtered = apply_filters( 'limit_uploads_for_roles', $limit_roles, $user );
   if ( array_intersect( $limit_roles, $user->roles ) ) {
     $post = get_post( $id);
     if ( $post->post_author != $user->ID ) return;
     $count = get_user_meta( $user->ID, 'upload_count', true ) ? : 0;
     if ( $count ) update_user_meta( $user->ID, 'upload_count', $count - 1 );
   }
}

Thanks Giuseppe

How to change “Registration complete. Please check your e-mail.” message in wp-login.php

You can use this filter to change the default “Registration complete. Please check your e-mail.” message on wordpress.

add_filter( 'wp_login_errors', 'override_reg_complete_msg', 10, 2 );
function override_reg_complete_msg( $errors, $redirect_to ) {
   if( isset( $errors->errors['registered'] ) ) {
     $needle = __('Registration complete. Please check your e-mail.');
     foreach( $errors->errors['registered'] as $index => $msg ) {
       if( $msg === $needle ) {
         $errors->errors['registered'][$index] = 'Your new message here';
       }
     }
   }

   return $errors;
}

Thanks DaveRoss