Skip to content

Instantly share code, notes, and snippets.

View nikitasinelnikov's full-sized avatar

Mykyta Synelnikov nikitasinelnikov

  • ultimatemember.com
  • Kharkiv, Ukraine
View GitHub Profile
@nikitasinelnikov
nikitasinelnikov / functions.php
Created October 14, 2024 10:48
Ultimate Member >= 2.8.7. Add list table views instead of filter dropdown
function um_custom_add_status_links( $views ) {
remove_filter( 'pre_user_query', array( UM()->admin()->users_columns(), 'filter_users_by_status' ) );
$old_views = $views;
$views = array();
if ( ! isset( $_REQUEST['role'] ) && ! isset( $_REQUEST['um_user_status'] ) ) {
$views['all'] = '<a href="' . admin_url( 'users.php' ) . '" class="current">' . __( 'All', 'ultimate-member' ) . ' <span class="count">(' . UM()->query()->count_users() . ')</span></a>';
} else {
$views['all'] = '<a href="' . admin_url( 'users.php' ) . '">' . __( 'All', 'ultimate-member' ) . ' <span class="count">(' . UM()->query()->count_users() . ')</span></a>';
@nikitasinelnikov
nikitasinelnikov / functions.php
Last active October 4, 2024 11:04
Ultimate Member: Avoid wp_kses in um_loggedin shortcode content
function my_um_loggedin_inner_content_without_kses( $prepared_content, $content ) {
return apply_shortcodes( UM()->shortcodes()->convert_locker_tags( wpautop( $content ) ) );
}
add_filter( 'um_loggedin_inner_content', 'my_um_loggedin_inner_content_without_kses', 10, 2 );
@nikitasinelnikov
nikitasinelnikov / functions.php
Created July 24, 2024 09:24
Remove 'subscriber' role for 3rd-party users
function um_users_update_role() {
if ( isset( $_GET['um_remove_subscriber'] ) && '1' == $_GET['um_remove_subscriber'] ) {
$users = get_users(
array(
'fields' => 'ids',
'role__in' => array( 'um_gold-member', 'um_bronze-member', 'um_silber-member' ),
'number' => -1,
)
);
@nikitasinelnikov
nikitasinelnikov / functions.php
Last active March 25, 2024 22:46
Custom gender field and filter in member directory for it
function custom_um_query_args_c2n_gender__filter_meta( $skip, $query, $field, $value, $filter_type, $is_default ) {
if ( ! is_array( $value ) ) {
$value = array( $value );
}
// $join_alias is pre-escaped.
$query->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_alias} ON {$join_alias}.user_id = u.ID";
$values_array = array();
foreach ( $value as $single_val ) {
@nikitasinelnikov
nikitasinelnikov / functions.php
Created February 21, 2024 22:06
Get dumped data
add_action( 'init', 'my_custom_init' );
function my_custom_init() {
if ( isset( $_GET['check_lifeguard'] ) && '1' == $_GET['check_lifeguard'] ) {
global $wpdb;
$meta_results = $wpdb->get_results(
"SELECT um.*
FROM {$wpdb->usermeta} um
WHERE um.user_id IN('1736','1251')",
ARRAY_A
@nikitasinelnikov
nikitasinelnikov / functions.php
Created January 5, 2024 13:36
Ultimate Member: Change the WP_Post object (title, content, excerpt) for displaying the restricted post. Ignore or use your custom
// It works since the 2.2.3:
// Avoid changing the post title to the "restricted content title".
add_filter( 'um_ignore_restricted_title', '__return_true' );
// Avoid changing the post content to the "restricted content content" not recommended to use or use with caution!
add_filter( 'um_ignore_restricted_content', '__return_true' );
// Avoid flushing the post excerpt when post is restricted.
add_filter( 'um_ignore_restricted_excerpt', '__return_true' );
// It works since the 2.8.2:
/**
@nikitasinelnikov
nikitasinelnikov / class-user.php
Created November 22, 2023 09:42
Investigate double email issue
<?php
namespace um\core;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'um\core\User' ) ) {
@nikitasinelnikov
nikitasinelnikov / functions.php
Created November 13, 2023 12:03
Ultimate Member v2. Default sorting as verified + last login
// Select this option https://imgur.com/VM2tJhv
// for getting show verified users and active users(last login recent) first in result
function um_custom_verified_last_login( $query_args, $sortby ) {
if ( $sortby == 'verified_first' ) {
if ( empty( $query_args['meta_query'] ) ) {
$query_args['meta_query'] = array();
}
$query_args['meta_query'][] = array(
'relation' => 'OR',
@nikitasinelnikov
nikitasinelnikov / class-form.php
Created October 31, 2023 08:52
Probably fix by singleton
<?php
namespace um\core;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'um\core\Form' ) ) {
/**
@nikitasinelnikov
nikitasinelnikov / functions.php
Created October 18, 2023 10:37
Ultimate Member + Country State City Dropdown PRO: Custom callbacks for select fields Country, State, City
function um_customcb_populate_countries() {
$countries = array();
if ( ! function_exists( 'get_countries' ) ) {
return $countries;
}
$all_countries = get_countries();
if ( empty( $all_countries ) ) {
return $countries;
}