Thursday, December 29, 2022
HomeWordPress Developmentplugin improvement - Displaying an Uploaded Picture as a Customized Avatar in...

plugin improvement – Displaying an Uploaded Picture as a Customized Avatar in WordPress


Am making a WordPress website whereby am enabling customers to add their very own customized profile pictures from a customized kind. As soon as they add am storing the picture URL in a database desk and the picture is then saved contained in the WordPress wp-content/uploads folder. This works fantastic

enter image description here

When a consumer logs in, I need to present the uploaded picture as an avatar in wordpress dashboard on the top-right nook as proven beneath. Ideally it ought to be Welcome take a look at [avatar-image]

enter image description here

My menus are created dynamically utilizing Wp Customized Navwalker. Henceforth all of the menus are added dynamically from the Admin dashboard underneath Look -> Menus.

I’ve tried utilizing a filter hook known as wp_nav_menu_objects to filter the menu and append the picture as an avatar however appears to not work.
Beneath is the filter hook am utilizing:

//Filter inside capabilities.php
perform my_dynamic_menu_items( $menu_items ) {

    foreach ( $menu_items as $menu_item ) {
        if ( strpos($menu_item->title, 'Welcome') !== false) {
        $menu_item->title="Welcome" . ' ' . get_avatar( get_the_author_meta( 'ID' ), 'medium' );
        }
    }
    return $menu_items;
}
add_filter( 'wp_nav_menu_objects', 'my_dynamic_menu_items', 10 );

Please help as I’ve tried doable choices however no success

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments