You can just update the option field avatar_default to your new image url:
add_filter( 'avatar_defaults', 'mytheme_default_avatar' );
function mytheme_default_avatar( $avatar_defaults )
{
$avatar = get_option('avatar_default');
$new_avatar_url = get_template_directory_uri() . '/images/default_avatar.png';
if( $avatar != $new_avatar_url )
{
update_option( 'avatar_default', $new_avatar_url );
}
$avatar_defaults[ $new_avatar_url ] = 'Default Avatar';
return $avatar_defaults;
}
Related Posts:
- how do you create an admin interface in plugin for your theme
- Get the blog page URL set in Options
- Using classes instead of global functions in functions.php
- What is the difference between wp_register_sidebar_widget and register_widget?
- Change admin bar to default:off
- Form Submitting Error with get_template_part()
- Create “File-less” Page Template in Functions.php
- What is the right way to include a wp-admin file in your theme?
- How to change admin bar color scheme in MP6 / WP 3.8 front end?
- TinyMCE custom styles remove class when switching styles
- When to use esc_url, esc_html, esc_attr, and friends?
- How to edit bbPress template files – WordPress + BuddyPress + bbPress? [closed]
- Hide certain pages / posts on wp-admin, show custom filter
- Adding Content Areas to Custom Page Template
- How to change post thumbnail title and alt attributes to post title?
- Why might $input (Settings API) be coming through empty?
- Where is default wp_head() implemented?
- Use local image for default avatar
- Override default cropping in WordPress [duplicate]
- Get password when user registers and save it sha1 into database
- Can’t edit style.css in subdirectory of my theme?
- How do I “unhook” / de-register jQuery so that it’s not called as part of wp_footer();?
- Removing the default sidebar from admin panel
- Merging PHP download script into `functions.php`
- Is there an error in get_the_tag_list()?
- Returning Variables back into a template
- Allow users to add custom functions to wordpress theme
- Enqueued Stylesheets Effecting Admin Styles
- Change date number to another language/script?
- How to add custom template tag in wordpress theme?
- Nesting Functions within Functions
- Is using eval() ok in this scenario
- Custom php page in WordPress theme?
- How to regenerate thumbnails when they’re stored on S3
- Can’t access WordPress functions in file called via Ajax?
- How can I customize wp_footer, where is the code that controls what this function does?
- Sub folder CSS that’s read by Admin panel
- How to list all images in uploads directory except those that are attached to any post
- wordpress custom theme import and export options for sample data [closed]
- Replace comment avatars and links at the same time
- More than one meta field in a single meta box?
- Is there a theme function for is_password_protected()?
- Warning/Error in Admin Panel while developing theme
- How to determine which custom header image is being shown
- Toggle Sidebar Display
- Why is the Links Manager visible?
- How to store functions in… functions.php?
- Unhook jQuery from WooCommerce via `functions.php`? [closed]
- trying to use wp_handle_upload with ajax
- Should I use include or load_template for including shortcodes, plugins and so on?
- Check if home.php and set home.php as page_on_front
- How to add Bootstrap Tour JavaScript to WordPress Admin Panel Dashboard Widget
- How to create a custom template to admin dashboard
- Should I use add_filter for functions in function.php of the theme?
- after renaming my wp-content folder, how do I upgrade my wordpress version?
- How to add a button which saves the post then executes a function
- Pass variable to hook. Its possible?
- Adding custom class to get_avatar() image doesn&https://wordpress.stackexchange.com/https://wordpress.stackexchange.com/#39;t work
- In this snippet how do I force the function to use gravatar rated G and fill in the alt for get_avatar()?
- Theme Customizer not loading JS for live preview
- Remove “You are using WordPress 3.2.1” from Right Now Dashboard Widget
- Replace function in a child theme
- Custom theme, contact form 7 & fast secure form doesn’t work
- WordPress admin-ajax.php
- Replace single_template filter with what for default posts?
- JQuery undefined and Stylesheet loads in bottom along with js files
- How to call the_time current?
- I’m using wp residence theme and want to display titile above the slider [closed]
- Iris color picker in custom theme option page not saving value
- How to add custom class to get_avatar()
- “options.php” not found
- Custom admin logo not showing after wordpress 4.5 upgrade
- Add content after get_header
- Can’t change theme name
- How to set default values for edit_post_link() in my theme?
- How to make excerpt image be full size instead of thumbnail?
- get_avatar() is not working in my custom theme
- Array for WordPress Avatar Size and Class
- WordPress uploads do not show up and I see the white screen of death in some cases
- Create a variable with string, array or multiple values
- How to add next height number in Order Attributes inside the Add new page. [duplicate]
- Show custom default avatar instead of gravatar
- How to remove menu from WP-Admin menu
- enqueue script if page is not equal to
- apply_filters to featured image
- Mamp pro permalink issues. Pages keep reverting to index.php
- Subsite theme mystery man replacement with Buddypress on main site [closed]
- loading custom.js file after jquery is loaded
- How to Disable Color Options?
- How do I make it super customisable?
- Creating custom function in wordpress to return data from database
- Getting URL of Resized Image
- Adding a new layout for genesis
- themeforce (happytables framework) implementation
- Setcookie not setting cookies anywhere except admin
- How to add a checkbox element to attachments editor with example
- Is tag default in WordPress?
- Why does WP recommend against custom favicon functionality in themes?
- What can I use for small text when converting to WordPress?
- Create new wordpress theme with no need update