• Good morning all,

    Excuse me for my English but I am French.

    I’m creating a custom field by default but I do not know how to set the label to read-only.

    
    function champ_temoignages_nom($postID) {
    	$post = get_post($postID);
    	if ($post->post_type == 'temoignages') {
    		add_post_meta($postID, 'nom', '', true);
    	}
    	return true;
    }
    

    I thank you for your help

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    I’m sorry, I don’t understand. Set what label to read-only? Where are you expecting this label to appear? Even with that resolved, it will not enforce a read only status. The post can still be changed by those with edit_post capability. Core WordPress does not have a read only status. Who can make changes or not is managed by capability for the entire post type, not individual posts.

    If you prefer, you could ask in the French language forums. You are still welcome to post here in any language you are comfortable with. You have options if you have difficulty explaining in English.

    Thread Starter barale61

    (@barale61)

    I thank you very much.

    Try the Advanced Custom Fields (ACF) plugin. It gives a lot of options for setting custom fields.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘add a custom read-only field’ is closed to new replies.