Support Forum ยป User Profile

Forum Replies Created

Viewing 15 posts - 196 through 210 (of 250 total)
  • Author
    Posts
  • in reply to: Metabox hidden using the same id #1422
    Tan NguyenTan Nguyen
    Participant

    Hi Cararina,

    Sorry for long response, we're still in progress to improving Conditional Logic. As this plugin uses Javascript to handle visibility of object and have to check many field conditional to generate results so it's hard to implements now. In your case, we'll have two ways to make it works natively:

    1. Save it as cel_product_apple, cel_product_android or cel_product_windowsphone in DB then use fone_id to check what's field to output.

    2. Save cel_product_apple, cel_product_android or cel_product_windowsphone in DB, then create another hidden field named cel_product, when post is saved, we also save the visible field to cel_product as an serialized array, then use unserialize function to show up.

    Example (2),

    
    add_filter( 'rwmb_meta_boxes', function( $meta_boxes )
    {
    	$meta_boxes[] = array(
    		'id' 			=> 'brand_product',
    		'title' 		=> 'Brands and Products',
    		'post_types' 	=> array( 'post', 'page' ),
    		'context'		=> 'normal',
    		'priority'		=> 'high',
    		'fields' => array(
    			array(
    				'id'	=> 'fone_id',
    				'name'	=> 'Brand',
    				'desc'	=> 'Pick Your Favourite Brand',
    				'type'	=> 'select',
    				'options' => array(
    					'apple' 		=> 'Apple',
    					'android' 		=> 'Android',
    					'windowsphone' 	=> 'WindowsPhone'
    				)
    			),
    			array(
    				'id' 	=> 'cel_product',
    				'type' 	=> 'hidden',
    			),
    			array(
    				'id' 	=> 'cel_product_apple',
    				'name'	=> 'Select your apple product?',
    				'type'	=> 'checkbox_list',
    				'options' => array('iPhone', 'iPad', 'iPod'),
    				'visible' => array( 'fone_id', 'apple' )
    			),
    			array(
    				'id' 	=> 'cel_product_android',
    				'name'	=> 'Select your android product?',
    				'type'	=> 'checkbox_list',
    				'options' => array('Galaxy', 'ZenPhone', 'Tablet'),
    				'visible' => array( 'fone_id', 'android' )
    			),
    			array(
    				'id' 	=> 'cel_product_windowsphone',
    				'name'	=> 'Select your apple product?',
    				'type'	=> 'checkbox_list',
    				'options' => array( 'Nokia', 'Galaxy' ),
    				'visible' => array( 'fone_id', 'windowsphone' )
    			)
    		)
    	);
    	return $meta_boxes;
    } );
    
    add_action('rwmb_before_save_post', function($post_id)
    {
    	// Get person ID to save from "Select a Customer" field
    	$metabox_to_save = $_POST['fone_id'];
    
    	// Save related field to phone field
    	if ( ! empty( $_POST["cel_product_{$metabox_to_save}"] ) )
    		$_POST['cel_product'] = serialize( $_POST["cel_product_{$metabox_to_save}"] );
    
    	// Clear all hidden meta boxes
    	foreach ( array('apple', 'android', 'windowsphone') as $field )
    	{
    		if ( $field !== $metabox_to_save )
    			unset( $_POST["cel_product_{$field}"] );
    	}
    } );
    

    To retrieve values in front end, just use:

    
    $cel_products = unserialize( rwmb_meta('cel_product') );
    

    Best regards

    Tan Nguyen

    in reply to: Conditional Logic/Groups not saving properly #1421
    Tan NguyenTan Nguyen
    Participant

    Thanks Sam very much for reporting this bug, we're working and release the patch for Group shortly ๐Ÿ™‚

    in reply to: Conditional Logic Between Checklist Group and Checkbox #1420
    Tan NguyenTan Nguyen
    Participant

    Dear Justin,

    I've checked with and it works, can you please tell me what's version you're using and provide your code to register meta boxes and define conditional logic?

    Here's my snippet for example:

    
    add_filter( 'rwmb_meta_boxes', function( $meta_boxes )
    {
    	$meta_boxes[] = array(
    		'id' => 'brand_product',
    		'title' => 'Brands and Products',
    		'post_types' => array( 'post', 'page' ),
    		'context'	=> 'normal',
    		'priority'	=> 'high',
    		'fields' => array(
    			array(
    				'id' => 'show_checkboxlist',
    				'name' => 'Show Checkbox List',
    				'desc' => 'Show Checkbox List when this checkbox is checked',
    				'type' => 'checkbox'
    			),
    			array(
    				'id'	=> 'brand',
    				'name'	=> 'Brand',
    				'desc'	=> 'Pick Your Favourite Brand',
    				'type'	=> 'checkbox_list',
    				'options' => array(
    					'Apple' 		=> 'Apple',
    					'Google' 		=> 'Google',
    					'Microsoft' 	=> 'Microsoft'
    				),
    				'visible' => array('show_checkboxlist', true)
    			)
    		)
    	);
    
    	return $meta_boxes;
    } );
    

    Best regards

    Tan

    in reply to: Conditional Logic Between Checklist Group and Checkbox #1419
    Tan NguyenTan Nguyen
    Participant

    Hi Justin, sorry for long silence, I'm checking this issue and give you an answer shortly ๐Ÿ™‚

    in reply to: Display element based on 'post' #1375
    Tan NguyenTan Nguyen
    Participant

    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
    Tan NguyenTan Nguyen
    Participant

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

    in reply to: Display element based on 'post' #1362
    Tan NguyenTan Nguyen
    Participant

    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
    Tan NguyenTan Nguyen
    Participant

    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
    Tan NguyenTan Nguyen
    Participant

    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
    Tan NguyenTan Nguyen
    Participant

    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
    Tan NguyenTan Nguyen
    Participant

    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
    Tan NguyenTan Nguyen
    Participant

    Did you have anoter Group field or other Meta Boxes?

    in reply to: Display element based on 'post' #1344
    Tan NguyenTan Nguyen
    Participant

    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
    Tan NguyenTan Nguyen
    Participant

    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 #1330
    Tan NguyenTan Nguyen
    Participant

    Hi Maurice,

    Yes, we do have shortcode to display on singular pages ๐Ÿ™‚

    
    [rwmb_meta meta_key="$meta_key"][/rwmb_meta]
    

    Where $meta_key is the field ID.

    To display post meta on other pages or specify post id meta, you can add post_id attribute, like so:

    
    [rwmb_meta post_id="$post_id" meta_key="$meta_key"][/rwmb_meta]
    

    Best regards

    Tan Nguyen.

Viewing 15 posts - 196 through 210 (of 250 total)