subscription page for logged in users
-
Know this is probably an odd request/inquiry but…
We’re using woocommerce’s my-account page for multiple things, and I’ve tried to implement a page for users to adjust their subscriptions there instead of the standard page, and that they’re redirected to that page if they change their subscription and are logged in.
Reason is to simplify users to see and change their newsletter subscriptions. Have a separate page there for them to directly see their newsletters.Was able to do it, but it required a lot of changes on multiple php files, so was wondering if there’s an easier to implement way to do it.
To keep them on the page after changing something:
hook_newsletter_action > switch > pe & ps (change “else” redicted):if( is_user_logged_in() ){ wp_redirect('my-account-newsletter-page'); } else { wp_redirect($profile_url);}switch > uc:
if( is_user_logged_in() ){ wp_redirect('my-account-newsletter-page'); } else { wp_redirect($url); }case > confirm:
if( is_user_logged_in() ){ wp_redirect('my-account-newsletter-page'); } else {$this->show_message('confirmed', $user);}So my question here, is there a better place to universally change the redirect?
And is there a hook for this so I could apply it in my functions.php file?Added a shortcode that’s loaded on my-account-newsletter-page,
newsletter/profile/profile.phpin the _construct() function:
add_shortcode('newsletter_my_account', array($this,'shortcode_newsletter_my_account'));under the _construct() function:
function shortcode_newsletter_my_account($attrs, $content) { $user = $this->get_user($attrs['id']); if ($attrs['token'] != $user->token) { $user = null; } if (empty($user)) { if (empty($content)) { return __('Subscriber not found.', 'newsletter'); } else { return $content; } } return $this->get_profile_form($user); }Is there a better way to do add a shortcode without changing your plugin’s php files?
We’ve been loving this plugin, and trying to combine it into the core website-usage for users.
The topic ‘subscription page for logged in users’ is closed to new replies.