I try to display a piece of text (without plugin) for example "Quote of the day: Some text" on all user profile pages (.../wp-admin/profile.php).
This Text should managable/editable from the Profile of the ADMIN. In the Admins Profile Page should be a Text Input field where i can change the Text and save.
Since yesterday i was not able to find any hint to achive this. I found a lot of tutorials to create custom User Field for the profile Page - but nothing like i need.
So far i was able to create a text input field where i can save the text (input) in the database and display it only in the admins profile page with:
function add_qoute_of_the_day_backend( $user ) {
// Visible only for admins
if( current_user_can( 'administrator' ) ) {
?>
<div class="visible-only-for-admin">
<h3>Quote of the Day Input Field</h3>
<table class="form-table" >
<tr>
<th><label for="qoute_of_the_day">Qoute of the Day</label></th>
<td><input type="text" name="qoute_of_the_day" value="<?php echo esc_attr(get_the_author_meta( 'qoute_of_the_day', $user->ID )); ?>" class="regular-text" /></td>
</tr>
</table>
</div>
<?php } ?>
<?php }
add_action( 'show_user_profile', 'add_qoute_of_the_day_backend', 10 );
add_action( 'edit_user_profile', 'add_qoute_of_the_day_backend', 10 );
function save_qoute_of_the_day_backend( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) )
return false;
update_user_meta( $user_id,'qoute_of_the_day', sanitize_text_field ( $_POST['qoute_of_the_day'] ) );
}
add_action( 'personal_options_update', 'save_qoute_of_the_day_backend' );
add_action( 'edit_user_profile_update', 'save_qoute_of_the_day_backend' );
The code above works, but how can i display the input of the admin, in Text Form (just: "Quote of the day: Some Text") in all other user profiles? Maybe any way to create a simple input field just for the admin Role and display the input in all profiles?
Visual - what im trying to achive:
INPUT FIELD in the profile page of the admin:
DISPLAY Text in all other user profiles:
Any help would be greatly appreciated