/** * Default role for users posting an idea on this site callback * * @package WP Idea Stream * @subpackage admin/settings * * @since 2.2.0 * * @uses checked() to add a checked attribute if needed * @uses wp_idea_stream_user_new_idea_set_role() to get the active option * @return string HTML output */ function wp_idea_stream_user_new_idea_set_role_setting_callback() { ?> <input name="_ideastream_user_new_idea_set_role" id="_ideastream_user_new_idea_set_role" type="checkbox" value="1" <?php checked(wp_idea_stream_user_new_idea_set_role()); ?> /> <label for="_ideastream_user_new_idea_set_role"><?php esc_html_e('Automatically set this site's default role for users posting a new idea and having no role on this site.', 'wp-idea-stream'); ?> </label> <?php }
/** * Set a role on the site of the network if needed * * @package WP Idea Stream * @subpackage users/functions * * @since 2.2.0 */ function wp_idea_stream_maybe_set_current_user_role() { if (!is_multisite() || is_super_admin()) { return; } $current_user = wp_idea_stream()->current_user; if (empty($current_user->ID) || !empty($current_user->roles) || !wp_idea_stream_user_new_idea_set_role()) { return; } $current_user->set_role(wp_idea_stream_users_get_default_role()); }