Forum Replies Created
-
AuthorPosts
-
Anh Tran
KeymasterAh, I got it.
To show the taxonomy on the front end, you need to create a field with the field type
taxonomyortaxonomy_advanced.The meta box for the taxonomy field on the right is the default WordPress's meta box, which won't show on the front end.
June 10, 2019 at 1:43 PM in reply to: ✅Allow editing form data which is submitted by "that" author #14909Anh Tran
KeymasterSorry, please try this code for the 2nd step:
add_filter( 'do_shortcode_tag', function ( $output, $tag, $attr ) { if ( $tag !== 'mb_frontend_form' || $attr['id'] !== 'my_form' ) { return $output; } // Check if current user is the post author. $post_id = filter_input( INPUT_GET, 'rwmb-post-id', FILTER_SANITIZE_NUMBER_INT ); if ( ! $post_id ) { return $output; } $post = get_post( $post_id ); if ( $post->post_author != get_current_user_id() ) { return 'You are not allowed to edit this post'; } return $output; }, 10, 3 );Anh Tran
KeymasterHi @Jefferson,
Can you post the code of the gallery field and do you know why the first item is empty?
June 10, 2019 at 11:55 AM in reply to: ✅Allow editing form data which is submitted by "that" author #14906Anh Tran
KeymasterIf you try to edit the existing posts, then only admin can edit them. Because their post author is the admin (technically when submitting posts, the plugin doesn't set the post author, and that falls back to the admin).
This code will work with new submitted posts, where the code in the step 1 sets the proper post author.
For the existing posts, you need to set the post author manually. Then the code will work properly.
Anh Tran
KeymasterHi Brian,
Can we actually do this with WooCommerce & the MB Custom Table or was this just a hypothetical example?
I'm afraid we can't. This involves a lot of the internal logic in WooCommerce. Modifying the data will break the logic and make it not working.
Anh Tran
KeymasterHi @SWS,
Did you mean that you're using a field type
taxonomyand it shows terms on the back end but not front end?Can you send some screenshots?
June 10, 2019 at 10:32 AM in reply to: ✅Allow editing form data which is submitted by "that" author #14899Anh Tran
KeymasterHi,
This is an interesting question. After checking around, this is the solution I found:
Step 1: set the post author when submitting
add_filter( 'rwmb_frontend_insert_post_data', function( $data, $config ) { if ( $config['id'] !== 'my_form' || ! is_user_logged_in() ) { return $data; } // Set current post ID as the author of the post. $data['post_author'] = get_current_user_id(); return $data; }, 10, 2 );Step 2: check if the current user is the post author
add_filter( 'do_shortcode_tag', function ( $output, $tag, $attr ) { if ( $tag !== 'mb_frontend_form' || $attr['id'] !== 'my_form' ) { return $output; } // Check if current user is the post author. $post_id = filter_input( INPUT_GET, 'rwmb-post-id', FILTER_SANITIZE_NUMBER_INT ); $post = get_post( $post_id ); if ( $post->post_author != get_current_user_id() ) { return 'You are not allowed to edit this post'; } return $output; }, 10, 3 );Anh Tran
KeymasterHi Sergio,
I know why. You need to pass the user ID to the function as the 3rd param. By default, the function takes the current post ID. So the code should be:
$images = rwmb_meta( 'avatar', ['object_type' => 'user', 'limit' => 1], get_current_user_id() );June 8, 2019 at 9:18 AM in reply to: ✅Error SQL when use in the query the fields from or to in table mb_relationships #14883Anh Tran
KeymasterHi Sergio,
The problem is
fromis a reserved keyword for MySQL. You can't use it directly in your SQL. To get over it, you need to put it in back ticks (`). Here is the modified SQL:(Can't post the SQL here because back ticks are used to insert code in this forum)
Anh Tran
KeymasterHi Nick,
I'm not sure about the syntax, you probably need to get help from BB team.
But in this case, you can use the MB Beaver Builder Integration to do the same using the Conditional Logic popup. Here is what I've tested:
Anh Tran
KeymasterHi Sergio,
The original post was about storing image data, e.g. storing full image in the DB.
In your case, you are using
image_advancedfield, which stores image IDs in the DB, which is the default behavior of the plugin and is totally fine. The data is automatically serialized, that's why you seea:2:{i:0;s:0:””;i:1;i:734;}.The reason your helper doesn't work is because you register the meta box for users. So, you need to set the
object_typefor therwmb_metafunction, like this:$images = rwmb_meta( 'info', array( 'object_type' => 'user', 'limit' => 1 ) );Anh Tran
KeymasterHi, I've just sent you the invoice via email. Please check it.
The invoice is sent manually since some company needs to fulfill their details such as address, register ID or VAT.
Anh Tran
KeymasterHi Ryan, I think this is a bug with the WYSIWYG field and I'll try to fix it soon.
-
AuthorPosts