edit_user_profile and show_user_profile are not firing inside a class
Where are you calling the class? A class by itself will do nothing unless it’s used. So, add at the very end $activate = new Test_Plugin();
Where are you calling the class? A class by itself will do nothing unless it’s used. So, add at the very end $activate = new Test_Plugin();
If you’re trying to get the last user created with the username format usuario*, I’d recommend using get_users() instead of writing a SQL query. $args = array( “search” => “usuario*”, // Search string “search_columns” => array( “user_login” ), // Field(s) to search “order” => “DESC”, // Search order “orderby” => “user_registered”, // Order by this … Read more
BuddyPress can be used as a framework – it allows you to friend other users, and is a good place to start from. [Update] This is the structure of the BuddyPress friends table (bp_friends) CREATE TABLE `wp_bp_friends` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `initiator_user_id` bigint(20) NOT NULL, `friend_user_id` bigint(20) NOT NULL, `is_confirmed` tinyint(1) DEFAULT ‘0’, … Read more
All you need to do is pass the current users email address into the get_avatar() function. <?php $current_user = wp_get_current_user(); if ( ($current_user instanceof WP_User) ) { echo get_avatar( $current_user->user_email, 32 ); } ?> Here are some links for specifics: get_avatar(); wp_get_current_user(); A response to your new problem in the comments below: <?php echo ‘<img … Read more
There is an excellent plugin solution for this: CIMY user extra fields I’m all for control and pro writing your routines, if ready-made solutions are not 100% satisfactory, but in the case of extended user profiles I have never seen the need. I am using this plugin myself on 2 production sites, very happy with … Read more
It’s not possible in WordPress to have shared users between 2 separates installations on 2 separated databases. It could be possible just by hardcoding: hardcode WP_User class connect to other database and retrieve users from there hardcode get_metadata() function, that for wp_usermeta table connect to other database and retrieve users from there but mentioned solution … Read more
You can add the function to both hooks: add_action(‘wp_ajax_ajaxTest’, ‘ajaxTest’); add_action(‘wp_ajax_nopriv_ajaxTest’, ‘ajaxTest’); But, there’s a better way to do it, use a REST API endpoint: add_action( ‘rest_api_init’, function () { register_rest_route( ‘yourstuff/v1’, ‘/test/’, array( ‘methods’ => ‘POST’, ‘callback’ => ‘yourstuff_test_endpoint’ ) ); } ); function yourstuff_test_endpoint( $request ) { $stuff = $request[‘stuff’]; return “Received “.esc_html( … Read more
Are you using WordPress 3.1+? There’s a nice get_users() function that’ll do the trick! However, you will need a little magic to boot: add_action( ‘pre_user_query’, ‘wpse_11832_pre_user_query’ ); /** * Adds “post_count” to the SELECT clause. Without this, the “post_count” * property for users will be undefined. * * @param object $wp_user_query */ function wpse_11832_pre_user_query( $wp_user_query … Read more
There’s the function human_time_diff( $from, $to );, which will compare two UNIX timestamps. Just use mktime() on $GLOBALS[‘current_user’]->user_registered; and compare it with the current UNIX time.
+1 @toscho ‘s comment. This will break nested comment / conversation in comment. You should disable nested comments in the Settings. Try this code. Note that this is not tested add_action( ‘delete_user’, ‘my_delete_user’); function my_delete_user($user_id) { $user = get_user_by(‘id’, $user_id); // delete comment with that user email $comments = get_comments(‘author_email=”.$user->user_email); foreach($comments as $comment) : wp_delete_comment($comment->$comment_id, … Read more