-
Notifications
You must be signed in to change notification settings - Fork 7
Description
So, I created some code to add the Privacy Tools Page to the My Account, for which I created a new menu item and endpoint.
In my case, it looks like this (everything into functions.php)
`add_filter ( 'woocommerce_account_menu_items', 'lvp_gdpr_link', 40 );
function lvp_gdpr_link( $menu_links ){
$menu_links = array_slice( $menu_links, 0, 5, true )
+ array( 'GDPR' => 'GDPR' )
+ array_slice( $menu_links, 5, NULL, true );
return $menu_links;
}
add_action( 'init', 'lvp_add_gdpr' );
function lvp_add_gdpr() {
// Add the GDPR link
add_rewrite_endpoint( 'GDPR', EP_PAGES );
// create the consents
gdpr('consent')->register( 'newsletter_consent', __('Je veux recevoir ma newsletter', 'le-vi-pe'), __('Je veux recevoir ma newsletter', 'le-vi-pe') );
}
add_action( 'woocommerce_account_GDPR_endpoint', 'lvp_gdpr_content' );
function lvp_gdpr_content() {
// of course you can print dynamic content here, one of the most useful functions here is get_current_user_id()
echo do_shortcode('[gdpr_privacy_tools]');
}`
Works like a charm!
Then I needed to change somethings to the way the privacy Tools Page is displayed (make it prettier), as per your documentations. I use lvpConsentForm to create a new form for consents.
$controller = gdpr(Codelight\GDPR\Components\PrivacyToolsPage\PrivacyToolsPageController::class);
remove_action('gdpr/frontend/privacy-tools-page/content', [$controller, 'renderConsentForm'], 10);
add_action('gdpr/frontend/privacy-tools-page/content', 'lvpConsentForm', 10, 2);
But, since I'm working from functions.php to create lvpConsentForm, this is where everything becomes awkward.
How do I create a new ConsentForm out of functions.php?
For instance, how do I have access to $dataSubject?
What do the urls look like when I want give consent to a consent-type that has been whitdrawn?
The purpose of it is to create a consent form that shows all consents (given or not) and that enables the dataSubject to adapt it freely (for instance, the consents that are not given or have been whitdrawn do not show up with your renderCustomForm)
Thanks for clarifying
Charles