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
Last active December 15, 2020 14:32
ForumWP: How to extends the topic data
function fmwp_topic_data_custom( $topic_args, $topic ) {
$author = get_userdata( $topic->post_author );
$topic_args['author_username'] = $author->user_login;
if ( ! empty( $topic_args['people'] ) ) {
foreach ( $topic_args['people'] as $people ) {
$user = get_userdata( $people['id'] );
if ( $topic->post_author == $people['id'] ) {
$people['avatar']['title'] = sprintf( __( 'Created by %s', 'forumwp' ), $user->user_login );
@nikitasinelnikov
nikitasinelnikov / functions.php
Created December 17, 2020 11:02
Ultimate Member - Google reCAPTCHA: Change language code based on WPML locale
function um_custom_recaptcha_language_code( $lang ) {
if ( UM()->external_integrations()->is_wpml_active() ) {
global $sitepress;
$language_code = $sitepress->get_current_language();
if ( $language_code == 'zh-hant' ) {
$lang = 'zh-TW';
}
}
@nikitasinelnikov
nikitasinelnikov / functions.php
Last active December 6, 2024 21:17
JobBoardWP: Custom fields on job posting form
// Please replace 'my-custom-key' to your real meta key
// there can be more than 1 custom meta fields
function jb_custom_job_data( $data, $job_id ) {
$data['my-custom-key'] = get_post_meta( $job_id, 'my-custom-key', true );
return $data;
}
add_filter( 'jb-job-raw-data', 'jb_custom_job_data', 10, 2 );
@nikitasinelnikov
nikitasinelnikov / functions.php
Created January 6, 2021 12:45
UM: Private Messages - Check if the users have conversations between theirselves and show this marker in profile header
function um_custom_markers( $args ) {
if ( is_user_logged_in() && ! empty( UM()->Messaging_API() ) ) {
if ( um_profile( 'ID' ) != get_current_user_id() &&
! empty( UM()->Messaging_API()->api()->get_conversation_id( um_profile( 'ID' ), get_current_user_id() ) ) {
echo 'some HTML with marker';
}
}
}
add_action( 'um_profile_header', 'um_custom_markers', 10, 1 );
@nikitasinelnikov
nikitasinelnikov / functions.php
Created January 12, 2021 12:48
Ultimate Member - Followers: How to remove followers bar from the user profile
function um_custom_profile_before_header( $args ) {
remove_filter( 'um_profile_tabs', 'um_followers_add_tabs', 2000 );
remove_action( 'um_profile_navbar', 'um_followers_add_profile_bar', 4 );
}
add_action( 'um_profile_before_header', 'um_custom_profile_before_header', 10, 1 );
@nikitasinelnikov
nikitasinelnikov / um-test-bar.php
Created January 15, 2021 13:09
Must User plugin for checking the conflicts
<?php
// if REMOTE_ADDR is empty or not correct you may use HTTP_X_FORWARDED_FOR or HTTP_CF_CONNECTING_IP
if ( isset( $_SERVER['REMOTE_ADDR'] ) && '{here your current IP}' == $_SERVER['REMOTE_ADDR'] ) {
if ( ! class_exists( 'UM_TEST_BAR' ) ) {
class UM_TEST_BAR {
@nikitasinelnikov
nikitasinelnikov / functions.php
Created January 26, 2021 23:16
Ultimate Member: Add reset filters and search button. Just clear URL and redirect to the fresh member directory URL
function um_custom_reset_member_directory( $args ) {
?>
<a href="<?php echo um_get_core_page( 'members' ) ?>" class="um-button um-alt"><?php _e( 'Reset', 'ultimate-member' ) ?></a>
<a>
<?php
}
add_action( 'um_members_directory_head', 'um_custom_reset_member_directory', 10, 1 );
@nikitasinelnikov
nikitasinelnikov / functions.php
Created February 23, 2021 14:50
JobBoardWP: Change job data in AJAX response on the jobs list
/**
* A job's custom data
*
* @param array $data
* @param WP_Post $job_post
*
* @return array
**/
function jb_custom_job_data( $data, $job_post ) {
$data = [
@nikitasinelnikov
nikitasinelnikov / functions.php
Created March 5, 2021 16:12
Ultimate Member: Make the user profile page restricted for not logged in users with restriction message
function um_custom_restriction_settings( $restriction, $post ) {
if ( ! is_user_logged_in() && um_is_core_post( $post, 'user' ) ) {
$restriction_meta = get_post_meta( $post->ID, 'um_content_restriction', true );
if ( $restriction_meta['_um_accessible'] == '2' && $restriction_meta['_um_noaccess_action'] == '0' ) {
$restriction = $restriction_meta;
}
}
return $restriction;
}
@nikitasinelnikov
nikitasinelnikov / functions.php
Created April 5, 2021 12:51
Ultimate Member: Unlock the ability to restrict the User Profile page
function um_custom_profile_restriction( $exclude, $post ) {
if ( $exclude ) {
if ( ! empty( $post->post_type ) && $post->post_type == 'page' ) {
if ( um_is_core_post( $post, 'user' ) ) {
$exclude = false;
}
}
}
return $exclude;
}