Custompress adding multiple choice "custom fields" options in bulk

How to add bulk options for
Multiselect or checkboxes
Have HUNDREDS of choices and it appears can only add them one at a time..

  • Michael Bissett

    Hey @be,

    In your case, I'd recommend hiring a developer to create this feature for you. You could hire one of the other Pros from our Jobs Board:

    https://premium.wpmudev.org/wordpress-development/

    Or you could post a job for this on another marketplace like oDesk, Elance, etc.

    If this was a small modification or a piece of code, we are usually more than happy to provide it right here. However, this is a bit more complex than can be handled by a quick fix.

    Thanks for your understanding! :slight_smile:

    Kind Regards,
    Michael

  • DavidM

    Hi @be, sorry if that seemed canned or lacking as a response at all. Rather, the issue is strictly that there's not a built-in way to allow bulk adding of custom fields currently, at least not without custom code. In this particular case, it would involve extensive code to handle it.

    Incidentally, there are some things in the works that could help provide that sort of feature in a future version. I realize that may not be feasible for you as it'll take some time before getting more specifics on it. As this has been added as a feature request though, it'll help to push it along.

    Sorry we don't have anything built-in to handle that right now but I was wondering if maybe the following plugin could help in your case?
    https://wordpress.org/plugins/custom-field-suite/

    It's specifically built for custom fields so it offers some very advanced features for them. I myself have used it extensively alongside CustomPress, it works great.

    It provides various ways to bulk add options, the easiest being to just use the Select field type and then copy-pasting in your options, one line per option.

    Would something like that maybe work better for you for the moment?

    Cheers,
    David

  • be

    Thanks @DavidM
    The reason to pay for support is NOT to have to develop ones own working version of your products.. That aside..

    Again the shortfalls are costly in time and workarounds.. but so be it...

    Thanks for the link. Will try and check it out, If that plugin required single entries then it is not much help. Could you please clarify...
    pasting in 600 x individual lines as opposed to copy and paste 1 x 600 entries is a world of difference..

    Is there a way to add directly to the table ?

  • Ash

    Hello @be

    I hope you are well today.

    Let me show you a way. For example, you wan to set 10 values (from 1 to 10) for a check box.

    1. So, just create one value (1) and save.
    2. Now open your theme's header.php and below body tag, use the following code:

    <?php
    	$cf = get_option( 'ct_custom_fields' );
    	echo '<pre>';
    	print_r($cf);
    	echo '</pre>';
    ?>

    3. Refresh your front page once, you will see some data like the screenshot 2.jpg. You have to search for the text "checkbox_" and you will see the checkbox element in there. If you have multiple checkbox, then you have to match the checkbox ID (point 'a'). In that array you will see field options and that is another array (point 'b'). And finally, within that array you will see the only value you entered in step 1 (point 'c').

    4. Then open header.php again remove my above code, and paste the following:

    <?php
    	$cf = get_option( 'ct_custom_fields' );
    	$array = array( 2, 3, 4, 5, 6, 7, 8, 9, 10 );
    	$data = array_merge( $cf['checkbox_549d3b13d0d7c']['field_options'], $array );
    	$cf['checkbox_549d3b13d0d7c']['field_options'] = $data;
    	$cf = update_option( 'ct_custom_fields', $cf );
    ?>

    You have to modify $cf['checkbox_549d3b13d0d7c']['field_options'] in the above code. Replace checkbox_549d3b13d0d7c with the correct ID you see in 2.jpg point 'a'.

    5. Now, this code run only ONCE.. Yes, only once.

    6. Remove the code

    7. Go to admin end to check if all values are added.

    Hope it helps :slight_smile: Please feel free to ask more question if you have.

    Cheers
    Ash