Forum Discussion

Re: RESOLVED: How to change Modern page Author from the "Created By" field to something else

Nope. Have same issue and we just had to live with it for now. I tried css injection but the css used for that field used some dynamic css class and can’t be used as it changes every so often.

The only thing I know that might be possible or using the rest call in flow but not sure it works SPO. I read up on it And decided it wasn’t worth the effort :p.

Last option is finding or creating your own news webpart.

11 Replies

  • Fromelard's avatar
    Fromelard
    Iron Contributor

    Thanks Christopher,

    The built-in web part does not give any parameter for that and the "See all" link is pointing also a built-in page impossible to change.

     

    I also check the page content type and found 2 "Author" fields, but without any change possible into.

     

    So, from my knowledge, the only way is to look from MS to change that setting.

    Except if someone has another genius idea :)

     

    Fab

      • Fromelard's avatar
        Fromelard
        Iron Contributor

        Dear Vesa,

        I tried to follow your recommendation via the script I wrote:

         

        [string]$SitePagesURL ="https://tenant.sharepoint.com/sites/SiteCollectionurl/subsite/"
        [string]$PageLibPublicName = "Site Pages"
        
        [int]$TempUserID = 0
        
        function Load-DLLandAssemblies
        {
        	[string]$defaultDLLPath = ""
        	# Load assemblies to PowerShell session 
        	$defaultDLLPath = "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll"
        	[System.Reflection.Assembly]::LoadFile($defaultDLLPath)
        	$defaultDLLPath = "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.Runtime.dll"
        	[System.Reflection.Assembly]::LoadFile($defaultDLLPath)
        	$defaultDLLPath = "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll"
        	[System.Reflection.Assembly]::LoadFile($defaultDLLPath)
        }
        Load-DLLandAssemblies
        
        #get and save your O365 credentials
        [string]$username = "AdminLogin@tenant.onmicrosoft.com"
        [string]$PwdTXTPath = "C:\SECUREDPWD\ExportedPWD-$($username).txt"
        $secureStringPwd = ConvertTo-SecureString -string (Get-Content $PwdTXTPath)
        $cred = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $secureStringPwd
        
        # ---------------------------------------------------------------------------------------------------------------
        #connect to the web site using the stored credentials
        Write-host " "
        Write-host " -------------------------------------------------------------------------------------------- " -ForegroundColor green
        Write-host " ---- CONNECT THE SITE --- " -ForegroundColor green
        Write-host "   CONNECTED SITE:", $SitePagesURL  -ForegroundColor Yellow
        
        $Myctx = New-Object Microsoft.SharePoint.Client.ClientContext($SitePagesURL)
        
        $Myctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($cred.UserName,$cred.Password)
        $Myctx.RequestTimeout = 1000000 # milliseconds
        $MyspoRootweb = $Myctx.Web
        $Myctx.Load($MyspoRootweb)
        $Myctx.ExecuteQuery()
        
        Write-Host " "
        Write-Host " ---------------------------------------------------------"
        Write-Host "  >>>> # Server Version:" $Myctx.ServerVersion " # <<<<<<" -ForegroundColor Green 
        Write-Host " ---------------------------------------------------------"
        Write-Host " "
        
        Write-host " -------------------------------------------------------- "
        Write-host "   -->> RootSite:", $MyspoRootweb.URL -ForegroundColor green
        
        Write-host " "
        
        $Alllists = $MyspoRootweb.Lists
        $MyPagelist = $Alllists.GetByTitle($PageLibPublicName)
        
        $MyPagelistItems = $MyPagelist.GetItems([Microsoft.SharePoint.Client.CamlQuery]::CreateAllItemsQuery())
        $Myctx.load($MyPagelistItems)
        $Myctx.executeQuery()
        
        foreach($PageItem in $MyPagelistItems)
        {
        	Write-Host "ID:", $PageItem["ID"], " - Title:", $PageItem["Title"]
        	$ModifiedByuser = $PageItem["Editor"]
        	$CreatedByuser = $PageItem["Author"]
        	if ($ModifiedByuser.LookupId -eq $CreatedByuser.LookupId)
        	{
        		Write-Host "       ===> Modified by: ", $ModifiedByuser.LookupValue, "[", $ModifiedByuser.LookupId, "] - Created by:", $CreatedByuser.LookupValue, "[", $CreatedByuser.LookupId, "]" -ForegroundColor Yellow
        	}
        	else
        	{
        		$TempUserID = $ModifiedByuser.LookupId
        		Write-Host "       ===> Modified by: ", $ModifiedByuser.LookupValue, "[", $ModifiedByuser.LookupId, "] - Created by:", $CreatedByuser.LookupValue, "[", $CreatedByuser.LookupId, "]" -ForegroundColor Red
        
        		$PageItem["Author"] = $TempUserID
        		$PageItem.Update();
        		$Myctx.ExecuteQuery();
        	}
        }  
        

        But nothing change at the "Created by" level, the change is apply for the "modified by" with my admin account used for that script execution.

         

        So my issue is not solved and i'm showing only the script execution account as news publisher.

         

        Thanks for your help if you have another way.

         

        Fab

Resources