Support Forum ยป User Profile

Forum Replies Created

Viewing 15 posts - 3,766 through 3,780 (of 3,958 total)
  • Author
    Posts
  • in reply to: image_advanced field not hidden #1403
    Anh TranAnh Tran
    Keymaster

    Hi bravebits,

    Does the answer in the topic https://support.metabox.io/topic/how-to-make-conditional-logic-for-image-upload/ solve your problem? My developer tested with similar code and said it was working.

    Regarding your code above, what is your $prefix? Is it wr?

    in reply to: Insert After Each Label in Radio Box Group #1394
    Anh TranAnh Tran
    Keymaster

    I think the best way to do that is via CSS. You can install a plugin like Add admin CSS. The CSS to make each label display in ins own line is quite simple:

    .rwmb-radio-wrapper .rwmb-input > label {
      display: block;
    }

    If you don't want to use a plugin, you can enqueue a CSS file on Add new/Edit page with the same snippet above.

    This way you also can add more margin to label for a better look.

    But if you have to use PHP to output line break after each label tag, please use rwmb_radio_html filter, like this:

    add_filter( 'rwmb_radio_html', function html( $output, $field, $meta )
    {
    	$html = array();
    	$tpl  = '<label><input type="radio" class="rwmb-radio" name="%s" value="%s"%s> %s</label>';
    
    	foreach ( $field['options'] as $value => $label )
    	{
    		$html[] = sprintf(
    			$tpl,
    			$field['field_name'],
    			$value,
    			checked( $value, $meta, false ),
    			$label
    		);
    	}
    
    	return implode( '<br>', $html );
    }, 10, 3 );
    in reply to: Looking to hire a developer #1384
    Anh TranAnh Tran
    Keymaster

    Hi Jon, let me ask my developer if he is interested in working freelance with you on that project and will reply you via email.

    Thanks.

    in reply to: Display element based on 'post' #1375
    Anh TranAnh Tran
    Keymaster

    Hi Jon,

    Sorry for late reply, I just back again and wonder to see that you can fix your code easily, brilliant.

    I can see you set 'column' => 4 for some 'hidden' fields, it's not necessary as these fields are hidden and some repeated code can be rewrite to cleaner ๐Ÿ˜‰

    All foreach like so:

    
    ...
    foreach ( $_POST as $key => $value )
    {
    	if ( strpos( $key, 'p52_quote_phone_' ) )
    		unset( $_POST[$key] );
    }
    ...
    

    Can be combine and rewrite to 1 foreach like so:

    
    foreach ( $_POST as $key => $value )
    {
    	if ( strpos( $key, 'p52_quote_phone_' ) || strpos( $key, 'p52_quote_company_' ) || strpos( $key, 'p52_quote_delivery_address' ) ... ) // Replace ... with all fake fields you've set
    	unset( $_POST[$key] );
    }
    

    For cloned group, I firstly designed for 1 product only and if we switch to cloned groups, it's time consuming because it's related to populate custom data and out of our scope, we're sorry about that.

    Best Regards

    Tan

    in reply to: Display element based on 'post' #1364
    Anh TranAnh Tran
    Keymaster

    Yeah, glad to meet you, an Australian who like Breaking Bad show like me ๐Ÿ™‚

    in reply to: Display element based on 'post' #1362
    Anh TranAnh Tran
    Keymaster

    Hi Jon, it's really weird if it return empty value even though customer phone has set. Can you please give me credentials to your website to check? Include FTP and WP-Admin? Can you send me via my email to check it faster? My email is: [email protected]

    in reply to: Display element based on 'post' #1359
    Anh TranAnh Tran
    Keymaster

    Can you please check the database (wp_postmeta) to see the records exists here?

    Basically, it grabs value from postmeta table and bind to meta box as I defined in this line:

    
     'std' 		=> get_post_meta( $customer->ID, 'p52_quote_phone', true ),
    

    So if the customer has phone entered, this should be bound to field via std key.

    I'm very happy to see you're going to the last steps ๐Ÿ™‚ This is a great challenge ๐Ÿ˜€

    in reply to: Display element based on 'post' #1354
    Anh TranAnh Tran
    Keymaster

    Oh, sorry, remove the square bracket and keep it $meta_box because I have assign $meta_boxes[] = $meta_box later ๐Ÿ˜‰

    in reply to: Display element based on 'post' #1351
    Anh TranAnh Tran
    Keymaster

    I means only remove square bracket only with $meta_box below, like my example in the previous page.

    
    // start customer
    
    in reply to: Display element based on 'post' #1349
    Anh TranAnh Tran
    Keymaster

    Hi Jon, I found another problem on your code:

    
    // start customer
    $meta_boxes[] = array(
    

    You can remove [], it just $meta_box.

    On step value, can you please change to full value contains zero sign, 0.01 instead of 'step' => .01?

    If you still get error, try to comment out some other Meta Box (I though is Groups), to check what meta boxes generate error ๐Ÿ™‚

    in reply to: Display element based on 'post' #1346
    Anh TranAnh Tran
    Keymaster

    Did you have anoter Group field or other Meta Boxes?

    in reply to: Display element based on 'post' #1344
    Anh TranAnh Tran
    Keymaster

    Hi carassius

    To explain it more clearly, I've basically created two fields, as defined in this array:

    
    'fields' => array(
    			array(
    				'name' => 'Name',
    				'id' => $prefix . 'name',
    				'type' => 'post',
    				'post_type' => 'customer',
    				'placeholder' => 'Select a Customer'
    			),
    			// Real field
    			array(
    				'name' 		=> 'Phone',
    				'id' 		=> $prefix . 'phone',
    				'type' 		=> 'hidden'
    			)
    		)
    

    There're two fields called p52_quote_name which type is is post and p52_quote_phone which is hidden field, this field will hold the real value. ($prefix = 'p52_quote_' as you defined)

    I've also created a bunch of input text fields, each field has ID: p52_quote_phone_$customer_id which customer ID is the post ID, and the default value is the customer phone, as this snippet:

    
    foreach ( $customers as $customer )
    	{
    		// Show this phone field if match name.
    		$meta_box['fields'][] = array(
    			'name' 		=> 'Phone',
    			'id' 		=> $prefix . 'phone_' . $customer->ID,
    			'type' 		=> 'text',
    			'std' 		=> get_post_meta( $customer->ID, 'p52_quote_phone', true ),
    			'visible' 	=> array( $prefix . 'name', $customer->ID )
    		);
    	}
    

    You can see

    
    'visible' 	=> array( $prefix . 'name', $customer->ID )
    

    That means, visible this field, when the select customer name is equal to customer ID, that means if we have two persons with phones, for example called:

    
    ID 1: Jim : 0123456789
    ID 2: Kane: 0139401451
    

    So, if Jim, ID 1 (p52_quote_name) is selected, the field, p52_quote_phone_1 will visible with default value defined in std is: 0123456789

    This snippet wich you've asked is to remove all faked text fields defined above, and store visible field (p52_quote_phone_1) to p52_quote_phone field ๐Ÿ™‚

    
    // Save data to phone field
    add_action('rwmb_before_save_post', function($post_id)
    {
    	// Get person ID to save from "Select a Customer" field
    	$person_to_save = intval( $_POST['p52_quote_name'] );
    	// Save related field to phone field
    	$_POST['p52_quote_phone'] = $_POST['p52_quote_phone_' . $person_to_save];
    	// Unset all hidden fields
    	foreach ( $_POST as $key => $value )
    	{
    		if ( strpos( $key, 'p52_quote_phone_' ) )
    			unset( $_POST[$key] );
    	}
    } );
    

    If you still have problem, can you give me your site information to debug?

    in reply to: Restrict Meta Box editing to Admin #1343
    Anh TranAnh Tran
    Keymaster

    Hi Jan,

    We're working MB Builder to release new version with contains improvement for roles & permissions. You'll get a update notice on this weekend.

    Thanks for using and reporting.

    in reply to: Show content in frontend #1342
    Anh TranAnh Tran
    Keymaster

    Hi Maurice,

    If you want to display meta value in a template file like single.php, please open that file (not functions.php) and insert the following code at the place you want to show the value:

    echo rwmb_meta( 'FIELD_ID', 'type=FIELD_TYPE' );

    Don't forget to change FIELD_ID and FIELD_TYPE to your specific field ID and field type.

    in reply to: Restrict Meta Box editing to Admin #1341
    Anh TranAnh Tran
    Keymaster

    Hi Jan,

    You can try the Include Exclude extension. It supports restricting by user role or by user ID and many other conditions.

Viewing 15 posts - 3,766 through 3,780 (of 3,958 total)