Limit number of posts a user can make per minute?

I would begin with establishing the most friendly approach to this. I think it would be a warning after post Publish/Update button is clicked. It is possible to prevent the Edit Post screen loading if the user re-visits it within 2 minutes after the previous post is published. I don’t think that is practical though … Read more

there’s a way to include a minimal WP for check only the current user, its roles (caps?) and then release/free it?

The no no about loading wp-* files directly are reasonable when you are developing a WordPress plugin or theme, but if you are developing an external code that require WP (and that seems your case) than you must require that files, there is no alternatives. Consider that including wp-blog-header.php is needed when you need to … Read more

Subscribers to posts

If for “all the conversations a user is in” you mean “all the conversations where a user has commented” you dont need any additional table, just a SQL to get all the posts of conversation CPT where an user commented. Here a function that should do the trick: /** * Get posts (of a given … Read more

How to add country drop down menu to the user profile?

Try this /* Save selected data */ add_action( ‘personal_options_update’, ‘save_user_fields’ ); add_action( ‘edit_user_profile_update’, ‘save_user_fields’ ); function save_user_fields( $user_id ) { if ( !current_user_can( ‘edit_user’, $user_id ) ) return false; update_usermeta( $user_id, ‘country’, $_POST[‘country’] ); } add_action( ‘show_user_profile’, ‘Add_user_fields’ ); add_action( ‘edit_user_profile’, ‘Add_user_fields’ ); function Add_user_fields( $user ) { ?> <h3>Additional Field</h3> <table class=”form-table”> <tr> <th><label … Read more

Set default page for user account in admin

You set a custom url after rewrite from a login. A small example, usable in a template of the theme to login. <?php $redirect = esc_url( ‘your-url’ ); if ( ! is_user_logged_in() ) { $link = ‘<a href=”‘ . get_option( ‘siteurl’ ) . ‘/wp-login.php?redirect_to=’ . home_url( “https://wordpress.stackexchange.com/” ) . ‘”>’ . esc_attr__( ‘Login’, ‘documentation’ ) … Read more

How to get top 10 user is based on user meta value

I guess you can do with get_users, something like: $topusers = get_users( array ( ‘meta_key’ => ‘todayuserclicks’, ‘meta_value’ => ”, ‘meta_compare’ => ‘!=’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘DESC’, ‘number’ => ’10’, ) );

Upload files programmatically to users

it was just missing $upload_dir[‘path’] . “https://wordpress.stackexchange.com/” . $upload_file_name in $uploaded_file[‘attach_id’] = wp_insert_attachment($attachment, $upload_dir[‘path’] . “https://wordpress.stackexchange.com/” . $upload_file_name); require_once(ABSPATH . ‘wp-admin/includes/image.php’); //Generate the metadata for the attachment, and update the database record. $attach_data = wp_generate_attachment_metadata($uploaded_file[‘attach_id’], $upload_dir[‘path’] . “https://wordpress.stackexchange.com/” . $upload_file_name);