New answers tagged users
2
You can store the data in the user meta as an array of post-id -> comment count at last visit and then simply count the comments since that date, for example
function get_user_comment_count_since_last_visit($user_id ,$post_id){
//only do this for logged in users
if ($user_id <= 0 ){
return 0;
}
/**
* get last comment count ...
0
WordPress should give this option below Attribute all posts to:
Anyhow, I wrote a post on this (Clean Comments Table After User Deleted)
Edit
Also, you can move your all posts from deleted users to admin user.
global $wpdb;
$admin_id = 1; // Assign admin user id here
$posts_table = $wpdb->prefix . 'posts';
$users_table = $wpdb->prefix . 'users';
...
1
It was actually much easier than I originally thought - just doing a WP_User_Query for a meta value (meta arrays are supported as well, like for the other query classes).
public function on_deactivate()
{
$meta_key = 'tools_page_tsi_per_page';
$query = new WP_User_Query( array( 'meta_key' => $meta_key ) );
if ( empty( $query->results ) )
...
0
If i understand the question correctly, you want that whenever a user adds a new post, all his/her previous posts should be deleted. I wonder why would you do that!! :) But anyway, you can use this code.
add_action('save_post', 'delete_prev_posts_by_user', 10, 2 );
function delete_prev_posts_by_user( $post_id, $post ){
if( 'publish' == ...
0
You can't add the ID at registration because there is no ID until after the user has registered. (See a possible way around this near the bottom).
You could tack on the ID after the registration with the user_register hook.
function add_ID_wpse_99390($a) {
global $wpdb;
$user = new WP_User($a);
$wpdb->query("UPDATE {$wpdb->users} SET user_login ...
0
First of all, you would use WP_User_Query instead of WP_User class to find the list of users. I wrote up a snippet to demonstrate this. I haven't tested it, so you might want to rewrite the whole thing. For reference, checkout this blog post http://mattvarone.com/wordpress/list-users-with-wp_user_query/ and the codex ...
1
I found the issue, thanks to @Toscho giving me the spark of an idea. We are using custom user roles and capabilities. It had something to do with the User Role Editor plugin. Deleted the custom role, and created a new one, reassigning all capabilities. Then updating all users to the newly created user role. Problem fixed.
Not sure why that happened, but ...
2
I am not going to write your form for you, but create a form and submit it to a page to do the processing, or use the AJAX API. Then use WP_User_Query to actually search for users. It is a very WP_Query-like class that should let you do everything you want including search for user metadata from the $wpdb->usermeta table by passing a meta_query parameter ...
1
Here is one idea to strip link- and image tags from the post content (before you save it) by using the edit_post_content filter and the wp_kses function:
add_filter( 'edit_post_content', 'my_edit_post_content', 10, 1 );
function my_edit_post_content( $content ) {
if (!current_user_can('manage_options')) { // only strip for non-admins
global ...
1
Assuming you're talking about the current user (as your code fragment shows), you'd call get_currentuserinfo() again.
Codex page for get_currentuserinfo()
0
The job was done by creating one new table. And storing the Category ID and the User Meta value each and every time the category is created.
Now, just list the category with the Created By value in the frontend.
Answer pulled from an OP comment.
0
Theoretically, this could be achieved by saving a user's password elsewhere, when he or she updates it.
Note that this sort of thing is hardly ever recommendable.
In almost all cases, there is a better architectural approach that renders having to be able to show plain-text passwords unnecessary.
That being said, if you absolutely must do it, this is how ...
3
User passwords are stored in the database as what is called a hash. hashes are not reversible even if you know the hash and the mechanism used to create it. The only way to "decrypt" a hash is to take a password, hash it, compare it against the target hash, and try again... over and over until you get a match. If you think about that, you aren't really ...
0
Found it! check the code below:
<?php
if ( is_user_logged_in() ) {
global $wpdb;
$user = wp_get_current_user();
$where = get_posts_by_author_sql( 'page', true, $user->ID );
$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" );
if ( $count >= 1 ) { ?>
//option 1 if ...
4
To list all pages with title and permalink from one user you need $wpdb->get_results(). The following code is based on this answer: How to count current user's pages?
First, we move the counter into a separate helper function; we might need it later again:
/**
* Get all post IDs and titles of a type for a user.
*
* @param int $user_id
* @param ...
2
Always use the existing functions, if those functions do what you need. That way, your code has the best chance of staying functional as the Core changes. If you make direct queries to the database then you have to keep track of changes to the database and alter your code accordingly.
Using Core functions also means that hooks have the best chance of ...
0
I've used this:
update_post_meta( $post->ID, 'your_meta_data'.$user_id, 'your_value' ); <= this will add for each user 1 field for that post, in db.
All Good :)
Top 50 recent answers are included
