You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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
The text was updated successfully, but these errors were encountered:
If you hook into gdpr/frontend/privacy-tools-page/content the $dataSubject object is injected into the hooked function automatically. It's always the data subject who is currently viewing the page. So in your case, you could simply do
function lvpConsentForm($dataSubject) {
// do your thing here
}
To get access to the ConsentManager class instance, you can simply do
$consentManager = gdpr('consent');
// and for example, to get all consent types to do your own thing with them:
$consentTypes = $consentManager->getConsentTypes();
The "framework" part might be a bit confusing right now, as not many people have used it like this yet - at least to my knowledge. So any feedback anyone can give me is very much appreciated! I want the plugin to be flexible enough that it's possible to adapt it to any kind of different business logic in a comfortable way.
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)
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.
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
The text was updated successfully, but these errors were encountered: