Hi Laura,
Thank you for sharing the summary again.
Your newly suggested approach of dropping the company selection field seems to be a good idea, as visitors will be clicking the sharing button from a specific company, already.
There will be a couple of steps involved, but the end result would be more efficient, both in terms of user experience and page loading.
1. You can add the following code to register two new shortcodes in your active theme's "functions.php" file, which will get the company's post ID from the URL and will return the name and the URL for the form:
add_shortcode( 'show-company-info-name', 'show_company_info_name_func');
function show_company_info_name_func($atts){
if( (isset($_GET['company-id'])) && (!empty( $_GET['company-id'])) ) {
$company_id = $_GET['company-id'];
$name = esc_html( get_the_title($company_id) );
if( !empty($name) ) {
return $name;
}
}
}
add_shortcode( 'show-company-info-url', 'show_company_info_url_func');
function show_company_info_url_func($atts){
if( (isset($_GET['company-id'])) && (!empty( $_GET['company-id'])) ) {
$company_id = $_GET['company-id'];
$URL = get_permalink($company_id);
if( !empty($URL) ) {
return $URL;
}
}
}
2. In your form, you can replace the existing company select field with the following generic field:
<div class="form-group">
<label>Company Information</label>
[cred_generic_field type='textarea' field='company info']
{
"required":0,
"default":"[show-company-info-name] - ( [show-company-info-url] )"
}
[/cred_generic_field]
</div>
3. Instead of loading the form multiple times on your archive page ( e.g. hidden link ), you can create a special dedicated page with the form ( similar to the one at hidden link )
Note: You can hide the extra page elements like header, footer and sidebar from that new form page, using custom CSS code.
4. When you'll pass on the company's ID through the URL parameter "company-id", the form will automatically show the name and the URL in that newly added field.
e.g. hidden link
In your archive page's loop, you can dynamically replace "123" with the current company's ID and set that new page to open in a new tab or popup, when its "Send to a friend link is clicked".
I hope this helps! Please let me know how it goes and if you need any further assistance around this.
regards,
Waqar