mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
- added upgrade for myCRED balance fields;
- fixed form_id PHP notice;
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
|
||||
function um_upgrade_balance_field215() {
|
||||
UM()->admin()->check_ajax_nonce();
|
||||
|
||||
um_maybe_unset_time_limit();
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$point_type = defined( 'MYCRED_DEFAULT_TYPE_KEY' ) ? MYCRED_DEFAULT_TYPE_KEY : 'mycred_default';
|
||||
|
||||
// update default sorting
|
||||
$wpdb->query(
|
||||
"UPDATE {$wpdb->postmeta}
|
||||
SET meta_value = IF( meta_value = 'most_mycred_points', 'most_mycred_default', IF( meta_value = 'least_mycred_points', 'least_mycred_default', meta_value ) )
|
||||
WHERE meta_key = '_um_sortby'"
|
||||
);
|
||||
|
||||
// Update role_select and role_radio filters to role
|
||||
$postmeta = $wpdb->get_results( "SELECT * FROM {$wpdb->postmeta} WHERE meta_key='_um_sorting_fields'", ARRAY_A );
|
||||
if ( ! empty( $postmeta ) ) {
|
||||
foreach ( $postmeta as $row ) {
|
||||
$meta_value = maybe_unserialize( $row['meta_value'] );
|
||||
|
||||
if ( is_array( $meta_value ) ) {
|
||||
$update = false;
|
||||
|
||||
if ( false !== ( $index = array_search( 'most_mycred_points', $meta_value ) ) ) {
|
||||
$meta_value[ $index ] = 'most_mycred_default';
|
||||
$update = true;
|
||||
}
|
||||
|
||||
if ( false !== ( $index = array_search( 'least_mycred_points', $meta_value ) ) ) {
|
||||
$meta_value[ $index ] = 'least_mycred_default';
|
||||
$update = true;
|
||||
}
|
||||
|
||||
if ( $update ) {
|
||||
update_post_meta( $row['post_id'], '_um_sorting_fields', $meta_value );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$custom_fields = get_option( 'um_fields', array() );
|
||||
|
||||
$forms_query = new WP_Query;
|
||||
$forms = $forms_query->query( array(
|
||||
'post_type' => 'um_form',
|
||||
'posts_per_page' => -1,
|
||||
'fields' => 'ids'
|
||||
) );
|
||||
|
||||
$field_for_upgrade = array();
|
||||
|
||||
foreach ( $forms as $form_id ) {
|
||||
$forms_fields = get_post_meta( $form_id, '_um_custom_fields', true );
|
||||
|
||||
foreach ( $forms_fields as $key => &$field ) {
|
||||
|
||||
if ( isset( $field['metakey'] ) && $point_type == $field['metakey'] ) {
|
||||
if ( empty( $field_for_upgrade ) ) {
|
||||
$field_for_upgrade = array(
|
||||
'type' => 'mycred_balance',
|
||||
'title' => $field['title'],
|
||||
'metakey' => $field['metakey'],
|
||||
'label' => $field['label'],
|
||||
'public' => $field['public'],
|
||||
'visibility' => $field['visibility'],
|
||||
);
|
||||
}
|
||||
|
||||
$field['type'] = 'mycred_balance';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
update_post_meta( $form_id, '_um_custom_fields', $forms_fields );
|
||||
}
|
||||
|
||||
if ( ! empty( $field_for_upgrade ) ) {
|
||||
$custom_fields[ $point_type ] = $field_for_upgrade;
|
||||
update_option( 'um_fields', $custom_fields );
|
||||
}
|
||||
|
||||
update_option( 'um_last_version_upgrade', '2.1.5' );
|
||||
|
||||
if ( ! empty( $field_for_upgrade ) ) {
|
||||
wp_send_json_success( array( 'message' => __( 'Balance fields were updated successfully', 'um-mycred' ) ) );
|
||||
} else {
|
||||
wp_send_json_success( array( 'message' => __( 'Updated successfully', 'um-mycred' ) ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
return array(
|
||||
'balance_field215' => 'balance_field215',
|
||||
);
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery( document ).ready( function() {
|
||||
um_add_upgrade_log( '<?php echo esc_js( __( 'Upgrade form fields...', 'ultimate-member' ) ) ?>' );
|
||||
|
||||
jQuery.ajax({
|
||||
url: wp.ajax.settings.url,
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
action: 'um_balance_field215',
|
||||
nonce: um_admin_scripts.nonce
|
||||
},
|
||||
success: function( response ) {
|
||||
if ( typeof response.data.count != 'undefined' ) {
|
||||
um_add_upgrade_log( response.data.message );
|
||||
//switch to the next package
|
||||
um_run_upgrade();
|
||||
} else {
|
||||
um_wrong_ajax();
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
um_something_wrong();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -939,7 +939,7 @@ function um_user_submitted_registration_formatted( $style = false ){
|
||||
function um_user_submited_display( $k, $title, $data = array(), $style = true ) {
|
||||
$output = '';
|
||||
|
||||
if ( 'form_id' == $k ) {
|
||||
if ( 'form_id' == $k && ! empty( $data['form_id'] ) ) {
|
||||
$v = sprintf( __( '%s - Form ID#: %s', 'ultimate-member' ), get_the_title( $data['form_id'] ), $data['form_id'] );
|
||||
} else {
|
||||
$v = um_user( $k );
|
||||
|
||||
+6
-1
@@ -146,7 +146,12 @@ The plugin works with popular caching plugins by automatically excluding Ultimat
|
||||
* To learn more about version 2.1 please see this [topic](https://wordpress.org/support/topic/version-2-1-4/)
|
||||
* UM2.1+ is a significant update to the Member Directories' code base from 2.0.x. Please make sure you take a full-site backup with restore point before updating the plugin
|
||||
|
||||
= 2.1.4: February 25, 2020 =
|
||||
= 2.1.5: March xx, 2020 =
|
||||
|
||||
* Bugfixes:
|
||||
- Fixed PHP notice 'form_id' on account submission
|
||||
|
||||
= 2.1.4: February 24, 2020 =
|
||||
|
||||
* Enhancements:
|
||||
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
Plugin Name: Ultimate Member
|
||||
Plugin URI: http://ultimatemember.com/
|
||||
Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress
|
||||
Version: 2.1.4
|
||||
Version: 2.1.5-beta1
|
||||
Author: Ultimate Member
|
||||
Author URI: http://ultimatemember.com/
|
||||
Text Domain: ultimate-member
|
||||
|
||||
Reference in New Issue
Block a user