{"id":507,"date":"2026-03-02T19:45:02","date_gmt":"2026-03-02T19:45:02","guid":{"rendered":"https:\/\/buddyupapi-staging.us35.cdn-alpha.com\/?page_id=507"},"modified":"2026-03-02T19:45:02","modified_gmt":"2026-03-02T19:45:02","slug":"create-adventure","status":"publish","type":"page","link":"https:\/\/buddyupapi-staging.us35.cdn-alpha.com\/create-adventure\/","title":{"rendered":"Create Adventure"},"content":{"rendered":"<div class=\"buddyUpPjaxContainer\" data-buddyup-pjax-container=\"1\"><style>#buddyUpTagSearchResults button {\n    width: 100%;\n}\n\n#buddyUpSelectedTags .singlePill {\n    cursor: pointer;\n}\n\n@media (max-width: 700px) {\n    #buddyUpCreateAdventureWrapper .buddyUpElWrapper {\n        padding: .7rem !important;\n    }\n}\n<\/style><section id=\"buddyUpCreateAdventureWrapper\" class=\"buddyUpContainer buddyUp\">\n    <div class=\"buddyUpHeaderWrapper flexWrapper\">\n        <h1 class=\"textH1\">Create Adventure<\/h1>\n    <\/div>\n\n    <div class=\"buddyUpElWrapper\" style=\"padding:1rem; margin-bottom:1rem;\">\n        <div class=\"buddyUpElWrapper\" style=\"padding:.7rem; margin-bottom:.75rem;\">\n            <label for=\"buddyUpAdventureTitle\" style=\"display:block;font-weight:600;margin-bottom:.35rem;\">Title<\/label>\n            <input id=\"buddyUpAdventureTitle\" class=\"buddyUpInput\" type=\"text\" placeholder=\"Sunrise hike at Blue Ridge\" \/>\n        <\/div>\n\n        <div class=\"buddyUpElWrapper\" style=\"padding:.7rem; margin-bottom:.75rem;\">\n            <label for=\"buddyUpAdventureBody\" style=\"display:block;font-weight:600;margin-bottom:.35rem;\">Post<\/label>\n            <textarea id=\"buddyUpAdventureBody\" class=\"buddyUpInput\" rows=\"5\" placeholder=\"Share your adventure details...\"><\/textarea>\n        <\/div>\n\n        <div class=\"buddyUpElWrapper\" style=\"padding:.7rem; margin-bottom:.75rem;\">\n            <div style=\"font-weight:600; margin-bottom:.35rem;\">Categories (required)<\/div>\n            <div class=\"buddyUpCategoryInputWrapper\" id=\"buddyUpAdventureCategoryWrapper\"><\/div>\n        <\/div>\n\n        <div class=\"buddyUpElWrapper\" style=\"padding:.7rem; margin-bottom:.75rem;\">\n            <div style=\"font-weight:600; margin-bottom:.35rem;\">Tag users and buddies<\/div>\n            <label style=\"display:flex;align-items:center;gap:.4rem;margin-bottom:.45rem;\">\n                <input type=\"checkbox\" id=\"buddyUpTagsOnlyBuddies\" checked=\"checked\" \/>\n                <span class=\"textSmall\">Only my buddies<\/span>\n            <\/label>\n            <input id=\"buddyUpTagSearchInput\" class=\"buddyUpInput\" type=\"text\" placeholder=\"Search users to tag\" autocomplete=\"off\" \/>\n            <div id=\"buddyUpTagSearchResults\" style=\"margin-top:.5rem;display:flex;flex-direction:column;gap:.35rem;\"><\/div>\n            <div id=\"buddyUpSelectedTags\" style=\"margin-top:.5rem;\"><\/div>\n        <\/div>\n\n        <div class=\"buddyUpElWrapper\" style=\"padding:.7rem; margin-bottom:.75rem;\">\n            <div style=\"font-weight:600; margin-bottom:.35rem;\">Photos<\/div>\n            <div id=\"myAdventureMediaInputWrapper\"><\/div>\n            <div class=\"textSmall\" style=\"opacity:.8; margin-top:.4rem;\">Images require EXIF geotag or selected location fallback.<\/div>\n        <\/div>\n\n        <div class=\"buddyUpElWrapper\" style=\"padding:.7rem; margin-bottom:.75rem;\">\n            <div style=\"font-weight:600; margin-bottom:.35rem;\">Video Links<\/div>\n            <div style=\"display:flex;gap:.5rem;flex-wrap:wrap;align-items:flex-start;\">\n                <input id=\"buddyUpAdventureVideoUrlInput\" class=\"buddyUpInput\" type=\"url\" placeholder=\"Paste a YouTube, TikTok, Facebook, Instagram, or Vimeo link\" style=\"flex:1;min-width:220px;\" \/>\n                <button id=\"buddyUpAdventureVideoAddBtn\" type=\"button\" class=\"buddyUpButton3\">Add Video Link<\/button>\n            <\/div>\n            <div id=\"buddyUpAdventureVideoLinks\" style=\"margin-top:.5rem;\"><\/div>\n            <div id=\"buddyUpAdventureVideoError\" class=\"buddyUpErrorMessage hidden\" style=\"margin-top:.45rem;\"><\/div>\n            <div class=\"textSmall\" style=\"opacity:.8; margin-top:.4rem;\">Videos are saved as platform links, not uploaded files.<\/div>\n        <\/div>\n\n        <div class=\"buddyUpElWrapper\" style=\"padding:.7rem; margin-bottom:.75rem;\">\n            <div style=\"font-weight:600; margin-bottom:.35rem;\">Visibility<\/div>\n            <div style=\"display:flex;gap:1rem;align-items:center;flex-wrap:wrap;\">\n                <label style=\"display:flex;align-items:center;gap:.35rem;\">\n                    <input type=\"radio\" name=\"buddyUpAdventurePrivacy\" value=\"private\" checked=\"checked\" \/>\n                    <span>Private<\/span>\n                <\/label>\n                <label style=\"display:flex;align-items:center;gap:.35rem;\">\n                    <input type=\"radio\" name=\"buddyUpAdventurePrivacy\" value=\"public\" \/>\n                    <span>Public<\/span>\n                <\/label>\n                <label style=\"display:flex;align-items:center;gap:.35rem;\">\n                    <input type=\"checkbox\" id=\"buddyUpAdventureShowOnMap\" \/>\n                    <span>Show on map<\/span>\n                <\/label>\n            <\/div>\n        <\/div>\n\n        <div id=\"buddyUpAdventureCreateError\" class=\"buddyUpErrorMessage hidden\" style=\"margin-bottom:.5rem;\"><\/div>\n\n        <div style=\"display:flex;gap:.5rem;align-items:center;flex-wrap:wrap;margin-bottom:70px;\">\n            <button id=\"buddyUpCreateAdventureBtn\" class=\"buddyUpButton1\" type=\"button\">Publish Adventure<\/button>\n            <a href=\"https:\/\/buddyupapi-staging.us35.cdn-alpha.com\/my-adventures\/\" class=\"buddyUpButton3\">Back to My Adventures<\/a>\n        <\/div>\n    <\/div>\n<\/section>\n<script>(async function(){\n    const wrapper = document.getElementById('buddyUpCreateAdventureWrapper');\n    if (!wrapper) return;\n\n    const currentUser = BUDDYUP.getCurrentUser();\n    if (!currentUser || !currentUser.id) {\n        wrapper.innerHTML = BUDDYUP.errorPage('Please log in', `<p>You must be logged in to create adventures.<\/p><a href=\"${buddyUpVariables.login_link}\" class=\"buddyUpButton1\">Log in<\/a>`);\n        return;\n    }\n\n    const categoryWrapper = document.getElementById('buddyUpAdventureCategoryWrapper');\n    BUDDYUP.interestsInputSetup(categoryWrapper, 'buddyUpAdventureCategories', 'category');\n\n    const mediaWrapperId = 'myAdventureMediaInputWrapper';\n    const mediaInputId = 'myAdventureMediaInput';\n    BUDDYUP.multiFileInputSetup(mediaWrapperId, mediaInputId, {\n        subscription: 2,\n        images: [],\n        requireAdventureLocation: true,\n    });\n\n    const adventureVideoLinksManager = BUDDYUP.initVideoLinksComposer({\n        listId: 'buddyUpAdventureVideoLinks',\n        inputId: 'buddyUpAdventureVideoUrlInput',\n        addButtonId: 'buddyUpAdventureVideoAddBtn',\n        errorId: 'buddyUpAdventureVideoError',\n        maxItems: 10,\n        allowDescription: true,\n        descriptionPlaceholder: 'Describe this video (optional)',\n    });\n\n    const createBtn = document.getElementById('buddyUpCreateAdventureBtn');\n    const createErr = document.getElementById('buddyUpAdventureCreateError');\n    const tagsInput = document.getElementById('buddyUpTagSearchInput');\n    const tagsOnlyBuddies = document.getElementById('buddyUpTagsOnlyBuddies');\n    const tagsResults = document.getElementById('buddyUpTagSearchResults');\n    const selectedTagsEl = document.getElementById('buddyUpSelectedTags');\n\n    let buddyIds = [];\n    const selectedTags = {};\n    let tagDebounce = null;\n\n    function setError(msg) {\n        if (!createErr) return;\n        if (!msg) {\n            createErr.classList.add('hidden');\n            createErr.innerHTML = '';\n            return;\n        }\n        createErr.innerHTML = msg;\n        createErr.classList.remove('hidden');\n    }\n\n    function parseCategoryPills() {\n        const pills = document.querySelectorAll('#buddyUpAdventureCategoryWrapper .singlePill');\n        const out = [];\n        pills.forEach((pill) => {\n            let text = String(pill.innerText || '').trim();\n            text = text.replace(\/\\s*[x\u00d7]\\s*$\/i, '').trim();\n            if (text) out.push(text);\n        });\n        return Array.from(new Set(out));\n    }\n\n    function renderSelectedTags() {\n        selectedTagsEl.innerHTML = '';\n        const tags = Object.values(selectedTags);\n        if (!tags.length) return;\n\n        tags.forEach((tag) => {\n            const id = `buddyUpSelectedTag_${tag.id}`;\n            selectedTagsEl.insertAdjacentHTML('beforeend', `<button id=\"${id}\" type=\"button\" class=\"singlePill\" style=\"margin-right:.35rem;margin-bottom:.35rem;\">${tag.name} \u00d7<\/button>`);\n            const btn = document.getElementById(id);\n            if (btn) {\n                btn.addEventListener('click', (e) => {\n                    e.preventDefault();\n                    delete selectedTags[tag.id];\n                    renderSelectedTags();\n                });\n            }\n        });\n    }\n\n    function renderTagResults(users) {\n        tagsResults.innerHTML = '';\n        if (!Array.isArray(users) || users.length === 0) return;\n\n        users.forEach((user, i) => {\n            if (!user || !user.id || selectedTags[user.id]) return;\n            const id = `buddyUpTagResult_${i}_${user.id}`;\n            const name = user.full_name ? String(user.full_name) : `User #${user.id}`;\n            const email = user.email_address ? String(user.email_address) : '';\n            tagsResults.insertAdjacentHTML('beforeend', `<button id=\"${id}\" type=\"button\" class=\"buddyUpButton3\" style=\"text-align:left;margin:0;\">${name}${email ? ` <span class=\"textSmall\" style=\"opacity:.8;\">(${email})<\/span>` : ''}<\/button>`);\n            const btn = document.getElementById(id);\n            if (btn) {\n                btn.addEventListener('click', (e) => {\n                    e.preventDefault();\n                    selectedTags[user.id] = { id: Number(user.id), name: name };\n                    tagsInput.value = '';\n                    tagsResults.innerHTML = '';\n                    renderSelectedTags();\n                });\n            }\n        });\n    }\n\n    async function fetchBuddyIds() {\n        const account = await BUDDYUP.apiRequest('account-get', {\n            id: currentUser.id,\n            include: 'buddies',\n            fields: 'id,buddies'\n        });\n        if (!account || account.status !== 'success' || !Array.isArray(account.buddies)) {\n            buddyIds = [];\n            return;\n        }\n        buddyIds = account.buddies.map((b) => Number(b.id)).filter((id) => id > 0);\n    }\n\n    async function searchUsersForTag() {\n        const q = tagsInput.value ? String(tagsInput.value).trim() : '';\n        if (q.length < 2) {\n            tagsResults.innerHTML = '';\n            return;\n        }\n\n        const resp = await BUDDYUP.apiRequest('users-admin-search', { search: q });\n        if (!resp || resp.status !== 'success' || !Array.isArray(resp.users)) {\n            tagsResults.innerHTML = '';\n            return;\n        }\n\n        let users = resp.users.filter((u) => u && Number(u.id) > 0 && Number(u.id) !== Number(currentUser.id));\n        if (tagsOnlyBuddies && tagsOnlyBuddies.checked) {\n            users = users.filter((u) => buddyIds.includes(Number(u.id)));\n        }\n\n        renderTagResults(users.slice(0, 8));\n    }\n\n    tagsInput.addEventListener('input', () => {\n        if (tagDebounce) clearTimeout(tagDebounce);\n        tagDebounce = setTimeout(searchUsersForTag, 240);\n    });\n\n    if (tagsOnlyBuddies) {\n        tagsOnlyBuddies.addEventListener('change', () => {\n            searchUsersForTag();\n        });\n    }\n\n    const privacyInputs = document.querySelectorAll('input[name=\"buddyUpAdventurePrivacy\"]');\n    const showOnMapInput = document.getElementById('buddyUpAdventureShowOnMap');\n    privacyInputs.forEach((input) => {\n        input.addEventListener('change', () => {\n            const isPublic = Array.from(privacyInputs).some((el) => el.checked && el.value === 'public');\n            if (!isPublic) {\n                showOnMapInput.checked = false;\n                showOnMapInput.setAttribute('disabled', 'disabled');\n            } else {\n                showOnMapInput.removeAttribute('disabled');\n            }\n        });\n    });\n\n    createBtn.addEventListener('click', async (e) => {\n        e.preventDefault();\n        setError('');\n\n        const title = String(document.getElementById('buddyUpAdventureTitle').value || '').trim();\n        const body = String(document.getElementById('buddyUpAdventureBody').value || '').trim();\n        const categories = parseCategoryPills();\n\n        const mediaInput = document.getElementById(mediaInputId);\n        const mediaDetailed = mediaInput && typeof mediaInput.getFilesDetailed === 'function'\n            ? mediaInput.getFilesDetailed()\n            : [];\n        const videoDetailed = adventureVideoLinksManager && typeof adventureVideoLinksManager.getMediaItems === 'function'\n            ? adventureVideoLinksManager.getMediaItems()\n            : [];\n        const allMedia = mediaDetailed.concat(videoDetailed);\n\n        const missingLocationMedia = mediaDetailed.filter((item) => {\n            if (!item || item.type !== 'image') return false;\n            const hasGeo = item.geotag && isFinite(Number(item.geotag.latitude)) && isFinite(Number(item.geotag.longitude));\n            const hasFallback = item.location_fallback && (\n                String(item.location_fallback.addressLabel || '').trim() !== '' ||\n                String(item.location_fallback.city || '').trim() !== '' ||\n                String(item.location_fallback.state || '').trim() !== '' ||\n                String(item.location_fallback.postalCode || '').trim() !== ''\n            );\n            return !hasGeo && !hasFallback;\n        });\n\n        const missingDescriptionMedia = mediaDetailed.filter((item) => {\n            if (!item || item.type !== 'image') return false;\n            return String(item.description || '').trim() === '';\n        });\n\n        if (!categories.length) {\n            setError('Please choose at least one category.');\n            return;\n        }\n\n        if (!title && !body && allMedia.length === 0) {\n            setError('Please add text\/title or upload at least one media item.');\n            return;\n        }\n\n        if (missingLocationMedia.length > 0) {\n            setError('One or more uploaded images are missing geotag\/location data. Please remove and re-upload those files, then select a location when prompted.');\n            return;\n        }\n\n        if (missingDescriptionMedia.length > 0) {\n            setError('Please add a description for each uploaded photo.');\n            return;\n        }\n\n        const selectedPrivacyEl = Array.from(document.querySelectorAll('input[name=\"buddyUpAdventurePrivacy\"]')).find((el) => el.checked);\n        const privacy = selectedPrivacyEl && selectedPrivacyEl.value === 'public' ? 'public' : 'private';\n        const showOnMap = privacy === 'public' && showOnMapInput && showOnMapInput.checked ? 1 : 0;\n\n        const taggedUsers = Object.values(selectedTags).map((t) => Number(t.id)).filter((id) => id > 0);\n\n        const payload = {\n            title: title,\n            body: body,\n            categories: categories,\n            tagged_users: taggedUsers,\n            media: allMedia,\n            privacy: privacy,\n            show_on_map: showOnMap,\n        };\n\n        createBtn.setAttribute('disabled', 'disabled');\n        const createResp = await BUDDYUP.apiRequest('adventures-create', payload);\n        createBtn.removeAttribute('disabled');\n\n        if (!createResp || createResp.status !== 'success') {\n            const msg = (createResp && (createResp.message || createResp.error)) ? (createResp.message || createResp.error) : 'Could not create adventure.';\n            setError(msg);\n            return;\n        }\n\n        document.getElementById('buddyUpAdventureTitle').value = '';\n        document.getElementById('buddyUpAdventureBody').value = '';\n        Object.keys(selectedTags).forEach((k) => delete selectedTags[k]);\n        renderSelectedTags();\n        tagsInput.value = '';\n        tagsResults.innerHTML = '';\n        BUDDYUP.multiFileInputSetup(mediaWrapperId, mediaInputId, {\n            subscription: 2,\n            images: [],\n            requireAdventureLocation: true,\n        });\n        if (adventureVideoLinksManager && typeof adventureVideoLinksManager.clear === 'function') {\n            adventureVideoLinksManager.clear();\n        }\n\n        BUDDYUP.openModal('Adventure created successfully.', 'Success', 'buddyUpAdventureCreateSuccess');\n    });\n\n    await fetchBuddyIds();\n})();\n<\/script><\/div>","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"templates\/full-width-no-header.php","meta":{"footnotes":""},"class_list":["post-507","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/buddyupapi-staging.us35.cdn-alpha.com\/api\/wp\/v2\/pages\/507","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buddyupapi-staging.us35.cdn-alpha.com\/api\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/buddyupapi-staging.us35.cdn-alpha.com\/api\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/buddyupapi-staging.us35.cdn-alpha.com\/api\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buddyupapi-staging.us35.cdn-alpha.com\/api\/wp\/v2\/comments?post=507"}],"version-history":[{"count":1,"href":"https:\/\/buddyupapi-staging.us35.cdn-alpha.com\/api\/wp\/v2\/pages\/507\/revisions"}],"predecessor-version":[{"id":508,"href":"https:\/\/buddyupapi-staging.us35.cdn-alpha.com\/api\/wp\/v2\/pages\/507\/revisions\/508"}],"wp:attachment":[{"href":"https:\/\/buddyupapi-staging.us35.cdn-alpha.com\/api\/wp\/v2\/media?parent=507"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}