Embed Snippet on Your Site
MemberPress: Import Dropdown Options for Custom Fields
This code snippet allows bulk import of dropdown options into the custom MemberPress dropdown field.
For this code snippet to work, a custom dropdown field must be created at Dashboard > MemberPress > Settings > Fields tab. Then, the mepr_custom_dropdown value should be replaced with the slug of that custom dropdown field, on the following line:
$key = 'mepr_custom_dropdown';
Next, options should be specified following this pattern:
$options[0] = array(
"option_name" => "Option 1 Name", // Option name
"option_value" => "Option 1 Value" // Option value
);
The dummy Option 1 name text should be replaced with the actual name of this dropdown option. Also, the dummy Option 1 value text should be replaced with the actual value to be stored (it can be the same).
This pattern should be copied and added for each additional dropdown option. For every option added, the number should be increased on this line within the pattern:
$options[0] = array(
The first option should have the value of 0, the second option should have the value of 1, as shown in the example. Accordingly, the next option should have a value of 2, and so on.
Save the code snippet (and activate the code) once all dropdown options are added.
To run this script, visit the following URL: [yoursite_url]?import-options=true (e.g. https://yourdomain.com?import-options=true). The “Options Imported Successfully!” message should be displayed to confirm the import.
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
Comments