How to sort a non-meta field in the User Admin Panel?

The WP_User_Query::parse_orderby() actually supports sorting by the number of posts, but because WP_User_Query::parse_orderby() limits by what users can be sorted, accomplishing a custom sort is a bit of a hack. Here’s the workaround I’ve created (semi-tested): add_filter( ‘manage_users_sortable_columns’, static function ( $columns ) { $columns[‘articles_count’] = array( ‘articles_count’, false, __( ‘Articles’ ), __( ‘Table ordered … Read more

How to build an expiring function in WordPress?

In this code we are getting the Publish Date using get_the_date() to retrieve the publish date of the current post. and then calculating the difference by comparing the publish date with the current date. After this we conditionally output the script. The condition is if the publish date is within the last 30 days, output … Read more

WP backend, Show only own comments (give to users who wrote/published/assigned) posts

Using the comments_pre_query filter, this seemed to work well in development and testing: /** * @param null $comment_data Return an array of comment data to short-circuit WP’s comment query. * @param WP_Comment_Query $query WP_Comment_Query instance, passed by reference. */ add_filter( ‘comments_pre_query’, static function ( $comment_data, $query ) { // Limit to admin area. if ( … Read more

install Segment on WordPress

add that code to a js in your theme folder (or child theme if you’re using it). for this example I named the script “analytics.js” and put it in a directory called “js” in my child theme folder. Now register and enqueue the file by placing this code in your functions.php function wpse_load_script() { // … Read more

Send An Email to Admin on User Profile Completion

Based on your question, you could simply call the WordPress function wp_mail( $to, $subject, $message, $headers ); when your var $user_progress[‘completion_percentage’] equal 100 %. <?php if( $user_progress[‘completion_percentage’] === 100 ) { // Complete your variables with original code $to = “[email protected]”; $subject = __(“New user registration”, “yourdomain”); $headers = array(‘Content-Type: text/html; charset=UTF-8’); $message = “A … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)