Hello, I would like my Course title field to have the name of the previous post where the registration button is and not the title of the form page. Thanks.
The page I need help with: [log in to see the link]
Good morning. Thanks for the answer. The first option worked perfectly. The second option “To generate that button’s URL dynamically for all courses, that PHP would look something like this:”, is not working. I put two links at the bottom of the page “https://ceforcivil.magicbrain.pt/site/seguranca-em-trabalhos-em-altura-e-utilizacao-de-arnes/”, one link with the first option, the other with the Second, if you could help me with the second option, I would be very grateful.
Ah, yes, I see the issue. The button is being inserted in a block so it converts the greater-than and less-than symbols into HTML entities so it doesn’t actually execute the code.
One of the great things about our built-in shortcodes is that they can be used in content anywhere that shortcodes are evaluated! So what we’ll do is update your button to use our CF7_get_current_var shortcode to retrieve the title instead of the PHP. Okay, follow these steps, I’ll include pictures to help:
With your paragraph highlighted in the editor, click the three-dots and choose “Edit as HTML.”
Screenshot of the block editor in WordPress with the meatballs menu open on a paragraph block, highlighting the option near the bottom of the menu that says “Edit as HTML”
Swap out that PHP code I wrote earlier with the shortcode like below:
Screenshot of the block editor in WordPress with the paragraph block in HTML editor mode, highlighting the use of a DTX shortcode in the URL as a value for a parameter.
You can click the “Edit Visually” button when done so it can show the pretty link. It won’t work in the backend, but once you publish it or preview the draft, you can see it work on the frontend as expected, click it, and you should see the URL at the top with the former page’s title in the query and then prepopulated in the form!
Screenshot of a page called Demo with a link that has ?title=Demo in it, showing the shortcode grabbed the page’s title.Screenshot of the page with the form that shows that the ?title=Demo worked and the page’s name Demo successfully prepopulated as Course Title.