Hot answers tagged

4

You forgot option 3 - Add a special table in which the pair (user,post id) will be the index. Ok I am not a MySQL person so maybe it is too extreme, but maybe having two tables one with users as index and one with posts will be even better. The thing about performance is that there are rarely absolute solutions for everybody at anytime, and the "best" ...


3

Trying to detect when a UI was triggered, is indeed the wrong general approach (unless you want to tie to the UI). A proper one will be to hook on the user_register action. add_action( 'user_register', 'wpse223196_registration_save', 10, 1 ); function wpse223196_registration_save( $user_id ) { add_user_meta($user_id, 'score', 5); }


3

Register a collection post type to represent a single collection. You'll get permalinks and rewrite rules to resolve the requests for free. Insert a new collection post for a user when they create a collection, and save the chosen post IDs as an array in post meta. You can pass that array directly as post__in argument in a WP_Query instance to load the ...


1

If I get it right you are storing this data in user meta. WP_Query would have no remote idea how to retrieve that, since it's only aware of post meta. The two are completely separate and there is no native way to involve one in queries for another. Likely you will have to do this in a two step process: Use get_users() to retrieve IDs for all authors of ...


1

The username is not a user meta entry, so you'll probably want to work with a WP_User object instead: $user = get_user_by( 'id', $_uid ); echo $user->user_login;



Only top voted, non community-wiki answers of a minimum length are eligible