How to Customize the Admin Area in EDD Dashboard
Explore available hooks for customizing the admin area in EDD Dashboard.
Note
We use the Codestar Framework for managing field creation.
Adding a Custom Menu to EDD Dashboard
Hook: edd_dashboard_register_new_fields
- Type:
Action
- Parameter:
$prefix
Implementation Example
add_action( 'edd_dashboard_register_new_fields', 'my_custom_edd_dashboard_field' );
/**
* Add a custom menu to the EDD Dashboard.
*
* @param string $prefix EDD Dashboard prefix.
*/
function my_custom_edd_dashboard_field( $prefix ) {
CSF::createSection(
$prefix,
array(
'title' => __( 'My Menu', 'edd-dashboard' ),
'fields' => array(
array(
'type' => 'subheading',
'content' => __( 'My Heading', 'edd-dashboard' ),
'class' => 'primary',
),
array(
'id' => 'opt-text',
'type' => 'text',
'title' => 'Text',
'default' => 'Hello world.',
),
array(
'id' => 'opt-textarea',
'type' => 'textarea',
'title' => 'Textarea',
'default' => 'Lorem ipsum dolor.',
),
),
)
);
}
Result
Here's how your custom menu appears in the EDD Dashboard:
Usage
To retrieve the saved option values, use the following code:
// Get the value from the 'opt-text' option
$get_text = edd__utils( 'main', 'get_option', 'opt-text' );
// Get the value from the 'opt-textarea' option
$get_textarea = edd__utils( 'main', 'get_option', 'opt-textarea' );
You can now easily access your custom settings and utilize them within your theme or plugin.
Last updated on