Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Privacy Tools Page #10

Open
cgrisar opened this issue May 23, 2018 · 1 comment
Open

Change Privacy Tools Page #10

cgrisar opened this issue May 23, 2018 · 1 comment

Comments

@cgrisar
Copy link

cgrisar commented May 23, 2018

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

@indrek-k
Copy link
Contributor

Great to see the plugin used like this!

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants