Skip to content

Instantly share code, notes, and snippets.

View wp-user-manager's full-sized avatar

wp-user-manager

View GitHub Profile
@wp-user-manager
wp-user-manager / wpum_likes_wp_query_order.php
Created January 2, 2023 22:05
WP User Manager - WP_Query ordering posts by the most likes
<?php
$args = array(
'post_status' => 'publish',
'post_type' => 'post',
'meta_key' => 'wpum_likes',
'orderby' => 'meta_value_num',
'order' => 'DESC'
);
@wp-user-manager
wp-user-manager / wpum_translate_profile_tab_slugs.php
Last active November 16, 2022 21:29
WP User Manager - Translate the profile URL slugs
<?php
function wpum_profile_tabs_translation_mapping() {
// Translated to Slovenian, change to your language
return array(
'about' => 'priblizno',
'posts' => 'objave',
'comments' => 'komentarj',
);
}
@wp-user-manager
wp-user-manager / wpum_allow_nickname_on_registration_form.php
Last active October 22, 2022 14:47
WP User Manager - Allow the nickname field to be added to registration forms
<?php
add_filter( 'wpum_non_allowed_fields', function ( $fields ) {
if ( ( $key = array_search( 'user_nickname', $fields ) ) !== false ) {
unset( $fields[ $key ] );
}
return $fields;
} );
@wp-user-manager
wp-user-manager / wpum_unload_styles.php
Created October 21, 2022 20:26
WP User Manager - Don't load the frontend CSS
<?php
function wpum_unload_styles() {
wp_dequeue_style( 'wpum-frontend' );
}
add_action( 'wp_enqueue_scripts', 'wpum_unload_styles', 11 );
@wp-user-manager
wp-user-manager / wpum_remove_links_already_logged_in_template.php
Created September 14, 2022 17:17
WP User Manager - Remove links from the Already Logged In template
@wp-user-manager
wp-user-manager / wpum_fix_account_profile_page_template.php
Last active July 26, 2022 17:25
WP User Manager - Fix account/profile sub-page templates in WP 6.0+
<?php
add_filter( 'template_include', function ( $template ) {
global $wp;
if ( ! isset( $wp->query_vars ) ) {
return $template;
}
if ( ! isset( $wp->query_vars['page_id'] ) ) {
@wp-user-manager
wp-user-manager / wpum_comment_author_url_as_profile.php
Last active July 26, 2022 17:22
WP User Manager - Make the comment author URL the user's profile URL
<?php
add_filter( 'get_comment_author_url', function ( $url, $id, $comment ) {
if ( $comment->user_id == 0 ) {
// Comment left by guest
return $url;
}
$user = get_user_by( 'id', $comment->user_id );
@wp-user-manager
wp-user-manager / wpum_disable_welcome_email_when_creating_user_manually.php
Created July 24, 2022 14:38
WP User Manager - Don't send welcome emails to users created via wp-admin
<?php
add_filter( 'wpum_send_registration_user_email', function ( $check ) {
if ( isset( $_POST['action'] ) && 'createuser' === $_POST['action'] ) {
return false;
}
return $check;
} );
@wp-user-manager
wp-user-manager / wpum_redirect_author_url_to_profile.php
Last active May 24, 2022 00:09
WP User Manager - Redirecting the author URL to the user profile
<?php
add_filter( 'author_link', 'wpum_author_link', 10, 2 );
function wpum_author_link( $link, $user_id ) {
$user = new \WP_User( $user_id );
return wpum_get_profile_url( $user );
}
@wp-user-manager
wp-user-manager / wpum_remove_account_nickname_validation.php
Created May 17, 2022 09:24
WP User Manager - Remove nickname validation from the account form
<?php
/**
* Remove an object filter.
*
* @param string $tag Hook name.
* @param string $class Class name. Use 'Closure' for anonymous functions.
* @param string|void $method Method name. Leave empty for anonymous functions.
* @param string|int|void $priority Priority