Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save craigcallen/8faf71a0f5783b5ad9134ec789f13b2b to your computer and use it in GitHub Desktop.
Save craigcallen/8faf71a0f5783b5ad9134ec789f13b2b to your computer and use it in GitHub Desktop.
Wordpress Yoast SEO - Remove user Social fields and Hide Yoast Profile settings (for non-Administrators)
<?php
if (!current_user_can('manage_options')) {
add_filter('user_contactmethods', 'fn_yoast_seo_remove_user_social_fields',99);
}
function fn_yoast_seo_remove_user_social_fields ( $contactmethods ) {
unset( $contactmethods['facebook'] );
unset( $contactmethods['instagram'] );
unset( $contactmethods['linkedin'] );
unset( $contactmethods['myspace'] );
unset( $contactmethods['pinterest'] );
unset( $contactmethods['soundcloud'] );
unset( $contactmethods['tumblr'] );
unset( $contactmethods['twitter'] );
unset( $contactmethods['youtube'] );
unset( $contactmethods['wikipedia'] );
return $contactmethods;
}
if (!current_user_can('manage_options')) {
add_action('admin_head', 'fn_yoast_seo_hide_settings_from_user_edit_screen');
}
function fn_yoast_seo_hide_settings_from_user_edit_screen() {
echo '<style>
.yoast-settings {
display: none;
}
</style>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment