@bharti18
You can try this code snippet, which will use two text fields from your User dashboard for the custom Title and Description by each User entry.
Meta keys for the text fields are my_seo_title
and my_seo_desc
If the fields are empty default values are used.
{display_name} | {site_name}
{display_name} is on {site_name}. Join {site_name} to view {display_name}'s profile
Test of the User description from the Profile field
{display_name} is on {site_name} and my birthdate is {usermeta:birth_date}
add_filter( 'um_template_tags_patterns_hook', 'my_template_tags_patterns', 10, 1 );
function my_template_tags_patterns( $placeholders ) {
$custom_tags = array( '{my_seo_title}', '{my_seo_desc}' );
return array_merge( $custom_tags, $placeholders );
}
add_filter( 'um_template_tags_replaces_hook', 'my_template_tags_replaces', 10, 1 );
function my_template_tags_replaces( $replace_placeholders ) {
$custom_replace = array();
$custom_replace[] = ( ! empty( um_user( 'my_seo_title' ))) ? um_user( 'my_seo_title' ) : "{display_name} | {site_name}";
$custom_replace[] = ( ! empty( um_user( 'my_seo_desc' ))) ? um_user( 'my_seo_desc' ) : "{display_name} is on {site_name}. Join {site_name} to view {display_name}'s profile";
return array_merge( $custom_replace, $replace_placeholders );
}
Install by adding the code snippet to your active theme’s functions.php
file
or use the “Code Snippets” Plugin
https://www.ads-software.com/plugins/code-snippets/
Edit:
You must also update the current SEO fields in
UM Settings -> General -> Users where you use the new tags
{my_seo_title}
{my_seo_desc}
for “User Profile Title” and “User Profile Dynamic Meta Description”
-
This reply was modified 7 months, 3 weeks ago by missveronica.