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_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_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_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_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_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
@wp-user-manager
wp-user-manager / wpum_content_restriction_by_users_or_groups.php
Created May 13, 2022 09:12
WP User Manager - Change the content restriction logic for users AND groups to users OR groups
<?php
add_filter( 'wpumcr_pre_post_restriction', function ( $is_restricted, $post ) {
$posts = array( 684, 685 ); // CHANGE THIS to the posts you want to restrict with the OR logic
if ( ! in_array( $post->ID, $posts ) ) {
return $is_restricted;
}
@wp-user-manager
wp-user-manager / wpum_rearrange_account_tabs.php
Created May 13, 2022 08:45
WP User Manager - Rearrange order of account page tabs
<?php
function my_wpum_rearrange_account_tabs( $tabs ) {
// Find the correct slug used in the URL, alter the priority
$tabs['email-subscriptions'] ['priority'] = 5;
return $tabs;
}
add_filter( 'wpum_get_account_page_tabs', 'my_wpum_rearrange_account_tabs', 100 );
@wp-user-manager
wp-user-manager / wpum_pass_url_query_strings_through_social_login.php
Created May 1, 2022 16:09
WP User Manager - Send URL query strings through the social login flow
<?php
add_filter( 'wpum_login_redirect_to_url', function ( $url ) {
if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
$url .= urlencode( '?' . $_SERVER['QUERY_STRING'] );
}
return $url;
} );
@wp-user-manager
wp-user-manager / wpum_do_not_generate_password.php
Created March 8, 2022 12:24
WP User Manager - Disable WPUM from generating a password if user registration is handled by another plugin
<?php
add_filter( 'wpum_new_user_notification_generate_password', '__return_false' );