• Resolved GregW

    (@gwmbox)


    I am trying to work out how I get the member pages added to the sitemap. The weird thing is that my profile as admin is listed but not others. I also do not want my profile listed in the sitemap.

    I am using the SEO Framework for my SEO and sitemaps, but even if I deactivate the plugin the WP sitemap still only includes my profile.

    What am I doing wrong or where is the setting I have missed?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @gwmbox

    Could you link me to the SEO Framework plugin? I’ll see if I can hook into their plugin and make it compatible with UM.

    Regards,

    Thread Starter GregW

    (@gwmbox)

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @gwmbox

    Please try adding the following code snippets to your theme’s functions.php file or use Code Snippet plugin:

    add_filter( 'the_seo_framework_sitemap_additional_urls', function( $custom_urls = [] ) {
    
        if( ! function_exists('um_get_core_page') ) return $custom_urls;
    
        $users = get_users();
       
        foreach( $users as $user ){
            $user_id = $user->ID;
            $user_profile_slug = UM()->user()->get_profile_link( $user_id );
            $last_date_modified = get_user_meta( $user_id, "um_last_date_modified",true );
            if( $last_date_modified ){
                $custom_urls["{$user_profile_slug}"] =  [
                    'lastmod'  => date('Y-m-d H:i:s', $last_date_modified ), // difficult to determine.
                ];
            }else{
                $custom_urls["{$user_profile_slug}"] =  [
                    'lastmod'  => $user->user_registered, // difficult to determine.
                ];
            }
        }
    	
    
    	return $custom_urls;
    } );
    
    add_action( 'um_after_user_updated', function( $user_id ){
        update_user_meta( $user_id, "um_last_date_modified", current_time('timestamp') );
    });

    The above code will add user profile URLs in the sitemap.xml

    The last modified date will fallback to user_registered date and when a user updates the profile it will use the last date when the profile is updated.

    To remove the admin from the list, you can customize the get_users function to retrieve users by specific role.

    To remove the existing admin account from the sitemap.xml, edit the Profile/User page > see “Page SEO Settings” > “Visibility” tab > see “Robots Meta Settings” > change the “Indexing” to “Noindex”.
    https://drive.google.com/file/d/1heuci2iyvUk-ZyhT-CaD3RwlcZzCDwj9/view

    Regards,

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hey there!

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. 🙂

    Regards,

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Sitemap for members’ is closed to new replies.