Skip to content

Instantly share code, notes, and snippets.

View yuriinalivaiko's full-sized avatar

Yurii Nalivaiko yuriinalivaiko

View GitHub Profile
@yuriinalivaiko
yuriinalivaiko / um_email_notifications_profile_is_complete.php
Last active June 4, 2023 21:44
This code adds custom email template "Profile Completeness - Profile is complete" to be used in the "Ultimate Member - Profile Completeness" extension.
<?php
if ( ! function_exists( 'um_email_locate_template' ) ) {
/**
* Locate a template and return the path for inclusion.
*/
function um_email_locate_template( $template_name ) {
$blog_id = is_multisite() ? '/' . get_current_blog_id() : '';
$template = locate_template(
@yuriinalivaiko
yuriinalivaiko / um_user_locations_map_args_customize_02.php
Last active October 26, 2023 11:29
This code snippet disables the ability to pan and zoom the map in the extension User Locations.
<?php
/**
* Disable the ability to pan and zoom the map.
*/
add_action( 'wp_footer', function () {
?><script type="text/javascript">
function um_user_locations_customize_02 ( args, hash, directory ) {
args.zoom = 4;
@yuriinalivaiko
yuriinalivaiko / um_profile_private_content_edit.php
Last active April 6, 2022 11:52
This code snippet adds a link "Edit private content" to the profile under the private content.
<?php
/**
* Add a button to the member profile that an admin can click so they are redirected to the private content of the relevant member
* @author Ultimate Member support <support@ultimatemember.com>
* @since 2022-03-17
* @see #59138
*/
add_action( 'um_profile_content_private_content', function( $args ) {
if ( is_user_logged_in() && current_user_can( 'administrator' ) && current_user_can( 'edit_user', um_profile_id() ) ) {
@yuriinalivaiko
yuriinalivaiko / um_profile_completeness_complete_profile_redirect.php
Last active July 10, 2022 11:12
Customize redirection after the profile is completed in the widget "Ultimate Member - Complete your Profile".
<?php
/**
* Redirection after profile is completed
* Add this code to the file functions.php in the active theme directory.
*/
add_filter( 'um_profile_completeness_complete_profile_redirect', function( $redirect, $user_id, $result ) {
if ( is_array( $result ) && absint( $result['progress'] ) >= absint( $result['req_progress'] ) ) {
$redirect = home_url();
@yuriinalivaiko
yuriinalivaiko / um_member_directory_notme.php
Last active July 10, 2022 11:08
This code snippet prevents members from being able to see themselves in the member directory.
<?php
/**
* Prevent members from being able to see themselves in the member directory.
* Add this code to the file functions.php in the active theme directory.
*/
function um_pre_users_query_notme( $directory ) {
if ( is_user_logged_in() ) {
$directory->where_clauses[] = 'u.ID != ' . get_current_user_id();
@yuriinalivaiko
yuriinalivaiko / jb_post_thumbnail_size.php
Last active October 6, 2022 17:53
This code snippet changes the job's company logo size in the JobBoardWP plugin.
<?php
/**
* Change the job's company logo size. Get rid of the cropped square logo. Use true logo image ratio.
* Add this code to the file functions.php in the active theme directory.
*/
/**
* Change the company logo size.
*
@yuriinalivaiko
yuriinalivaiko / um_display_all_form_errors.css
Last active April 24, 2024 13:06
Display all form errors below the form in Ultimate Member
/**
* Hide error messages under fields.
*/
.um-field .um-field-error {
display: none;
}
@yuriinalivaiko
yuriinalivaiko / js_code_snippet.js
Last active August 3, 2022 10:59
Use one of these code snippets to fix a form view in popup. This example uses a button selector for the Elementor popup. Change a button selector to use this code with another popup plugin.
/**
* A code snippet that triggers the "resize" once the popup is open.
* Add this code to your custom JS file.
*/
jQuery( '.elementor-button[href^="#elementor-action"]' ).on( 'click', function () {
setTimeout( function() {
jQuery( window ).trigger( 'resize' );
}, 100 );
} );
@yuriinalivaiko
yuriinalivaiko / um_sitemaps_users.php
Last active February 12, 2023 20:38
This code snippet adds all approved users whose Ultimate Member profiles are public to the sitemap.
<?php
/**
* Add all approved users whose Ultimate Member profiles are public to the sitemap.
* Add this code to the file functions.php in the active theme directory.
*/
add_filter( 'wp_sitemaps_max_urls', 'um_sitemaps_users_max_urls', 10, 2 );
add_filter( 'wp_sitemaps_users_pre_max_num_pages', 'um_sitemaps_users_max_num_pages', 10, 1 );
add_filter( 'wp_sitemaps_users_pre_url_list', 'um_sitemaps_users_get_url_list', 10, 2 );
@yuriinalivaiko
yuriinalivaiko / re-initialize_dropdown_fields.js
Last active November 27, 2022 13:02
This code snippet can fix a dropdown functionality in Ultimate Member if it is broken due to plugins conflict.
/**
* Re-initialize dropdown functionality.
* Add this code to your custom JS file.
*/
jQuery( function () {
/**
* Verifies that there is no empty value.
*/
function unselectEmptyOption( e ) {