Forum Replies Created
-
AuthorPosts
-
Anh Tran
KeymasterHi Kevin,
I've just checked and don't see the message. Have you updated to the latest version?
Also can you check if your meta box contains any field with ID
email? This field coincide with WP user field and might trigger the create user action (it doesn't trigger in my test, but maybe in yours).Anh Tran
KeymasterHi Arif,
This is more related to sorting values in PHP rather than with Meta Box. I'll try to give you the concept of doing that, please follow it. Your logic is complicated and I couldn't provide full code for you.
As I see you store all teams and their info in a group field
goalkick_league_point_table_option, right? And for each team, you record the number of matches that the team won or lost, right? (I assume that, cause I don't know if that's the number of matches or number of scores for matches).To sort teams, we will need to use usort() function.
Here is my first idea for sorting by scores:
function get_score( $team_details ) { $win = isset( $team_details['goalkick_league_standing_match_win_manual'] ) ? $team_details['goalkick_league_standing_match_win_manual'] : 0; $lost = isset( $team_details['goalkick_league_standing_match_win_manual'] ) ? $team_details['goalkick_league_standing_match_loss_manual'] : 0; return $win * 3; } $teams = rwmb_meta( 'goalkick_league_point_table_option' ); usort( $teams, function( $a, $b ) { $a_score = get_score( $a ); $b_score = get_score( $b ); if ( $a_score == $b_score ) { return 0; } return $a_score > $b_score ? -1 : 1; } );If you want to check by other conditions (2 and 3), then in the callback function of
usort, add more conditions, like this:usort( $teams, function( $a, $b ) { $a_score = get_score( $a ); $b_score = get_score( $b ); // Scores equal, sort by matches played. if ( $a_score == $b_score ) { $a_matches = get_matches( $a ); $b_matches = get_matches( $b ); // If matches equal, sort by something else. if ( $a_matches == $b_matches ) { } return $a_matches > $b_matches ? -1 : 1; } return $a_score > $b_score ? -1 : 1; } );Anh Tran
KeymasterHi Jay,
In a recent update, the default fields (username and password) was removed from the profile field. It's requested by some users. To re-add them, please add
id="rwmb-user-info"to the shortcode. For details, please see the docs.Anh Tran
KeymasterIt's fixed. Thanks for your feedback!
Anh Tran
KeymasterYou're data is a plain array encoded in JSON, so
$value[$i]is correct to iterate each of the value stored.I'm not sure how it's saved in the DB, though. But at least it works for now. Please post the code for the meta box/field here for me to see why it saves as json-array.
Anh Tran
KeymasterI got it. Let's try to fix the issue with the BB first.
Please deactivate everything related to Pods, since we don't need it anymore.
On the front end, if you keep your old modules / shortcodes, then the custom fields with Pods might be still outputted correctly. It's not a bug, it's just BB can still retrieve data from custom fields even when the plugin is deactivated. (Of course, the data is still in the database, so BB is able to retrieve it).
Regarding fields that you created with Meta Box, can you check if you installed and activated the MB Beaver Builder Integration extension? This extension helps you to output the custom field easier. See the screenshot on the plugin page and let me know if there's anything unclear.
Anh Tran
KeymasterHi Sam,
If you already activate MB Relationships network-wide, then please do not install or activate the plugin via Meta Box AIO. The AIO plugin is a wrapper of other extensions. When you install a plugin via AIO, it will install that plugin as an individual plugin, which can cause some issues.
January 20, 2019 at 10:29 AM in reply to: ✅Set default value to field if this value still not exist #13076Anh Tran
KeymasterHi Jefferson,
Yes, it works only for new posts, since
stdis used when the meta box has not been saved before. For old posts, obviously meta box is already saved. So you need to do some migration. Perhaps you should share with us here ;). I think many users like that.I'll fix the issue with My topics link now.
Anh Tran
KeymasterHi Max,
Does it work with new posts?
The mechanism of
stdin Meta Box works only if the meta box has not been saved before. Here 'meta box' means all fields. So if there's any field that already has value, thenstdwon't work for other fields, even new fields you've just added.Anh Tran
KeymasterHi Sam,
From the error, I think the MB Relationship is already activated on a sub-site before. Can you check that and make sure no sub-site activate the plugin before you activate it in the network?
Anh Tran
KeymasterHi Sam,
Did you create the custom table with code? The MB Custom Table doesn't create the table automatically. Instead, you need to put a small snippet into your theme's
functions.phpfile to create a table manually. Here is the guide on doing that.If you already did that but no tables are created, please check if your database user has privileges to create new tables. Some hosts don't allow you to do that.
Regarding issue with displaying fields on the front end, are the fields just normal custom fields or they're fields used with custom table? As there is still a problem with custom table, the custom fields don't work properly until we resolve it.
I'll answer your question about MB Relationships in another topic of yours.
Anh Tran
KeymasterHi Mark,
The shortcode in BB is a wrapper version of rwmb_the_value() helper function. For terms, it returns a link to that term. And there's no extra arguments at the moment. We'll try to improve that later. It's might be a nice improvement for not only terms, but also posts, users, images.
@Sam: I'll answer you in your topics.
Anh Tran
KeymasterHi Sam,
Thanks for your feedback. I'll check and fix that.
Anh Tran
KeymasterBoth rwmb_* functions and WordPress's get_post_meta() don't use JSON at all. They use serialize for arrays. Maybe you need to check how data is saved in your case, just to make sure it's valid. Anyway, as the data is there, you can use json_decode function to decode it.
January 18, 2019 at 4:24 PM in reply to: ✅Set default value to field if this value still not exist #13053Anh Tran
KeymasterHi Jefferson,
You can use
stdattribute for a text field, like this:$post_id = isset( $_GET['post'] ) ? intval( $_GET['post'] ) : ( isset( $_POST['post_ID'] ) : intval( $_POST['post_ID'] ) : false ); $meta_boxes[] = [ 'fields' => [ [ 'type' => 'text', 'id' => 'color', 'std' => generate_my_own_code( $post_id ), ], ], ]; -
AuthorPosts