Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example to use the User List Dropdown for Customizer, the classes are inside the project: https://github.com/bueltge/Wordpress-Theme-Customizer-Custom-Controls
<?php
/**
* @see: https://github.com/bueltge/Wordpress-Theme-Customizer-Custom-Controls
*/
add_action( 'customize_register', 'fb_customize_register' );
function fb_customize_register( $wp_customize ) {
require_once( 'class-user_select_custom_control.php' );
$wp_customize->add_section(
'my_theme_blog_featured_user_list', array(
'title' => __( 'Featured User List', 'textdomain' ),
'priority' => 36,
'description' => __( 'Manage User List', 'textdomain' ),
)
);
$wp_customize->add_setting(
'featured_user_list_1', array(
'default' => __( 'Default User', 'textdomain' ),
)
);
$wp_customize->add_control(
new User_Select_Custom_Control(
$wp_customize, 'featured_user_list_1', array(
'label' => __( 'Featured User List 1', 'textdomain' ),
'section' => 'my_theme_blog_featured_user_list',
'settings' => 'featured_user_list_1',
'description' => __( 'Select a User from List', 'textdomain' ),
'query' => array( 'role' => 'author' ),
)
)
);
return $wp_customize;
}
@Tantumonium
Copy link

Tantumonium commented Apr 11, 2018

Greetings,

I currently use your excellent "Multisite Enhancements" plug-in, and found this project when looking to see what other helpful things you may have created. I've done a ton of web development over the years (pretty much HTML, CSS, and JavaScript/jQuery), but am just learning PHP and the wonderfully complex underside of WordPress.

I'm pretty familiar w/ adding PHP code sections to my WP installation (via functions.php, shortcodes, and per-page injection). I have recently added a function to populate a Gravity Forms dropdown w/ a list of WP registered usernames, but I would much rather use an established code-base from a seasoned developer. :)

Anyway... I hoping you would be willing to explain a bit more about how someone like myself could begin implementing your "Wordpress-Theme-Customizer-Custom-Controls".

Cheers, Dustin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment