Add checkbox frontend and save meta

Support MB Frontend Submission Add checkbox frontend and save metaResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #23994
    ben06ben06
    Participant

    I'm creating a reading check system :

    I created a metabox block (fields groups) with only one checkbox field.

    I want it to display on frontend if this metabox is used in back office.

    Then I want to save the meta (checked) when someone check it and keep the checkbox checked after refresh.

    Can someone help me?
    Thank you for your time.

    #24016
    Long NguyenLong Nguyen
    Moderator

    Hi Ben,

    The field checkbox helps you to create a checkbox on the backend when editing a post (or post type) then show the value on the frontend with the helper function rwmb_meta(). You can create a condition to show something on the frontend if the box is checked on the backend.

    $value = rwmb_meta( $field_id );
    // If field is checked.
    if ( $value ) {
        echo 'Checked';
        // Do something.
    }
    // If field is unchecked.
    else {
        echo 'Unchecked';
        // Do something else.
    }
    #24024
    ben06ben06
    Participant

    Thank you for your answer!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.