[Closed] Shop account target link
Hello all,
Is there a way to change the target link of the “Shop account” button in the user’s profile page?
Thank you!
you can use this code
add_action( 'wp_head', function () { ?>
<script>
jQuery(document).ready(function($) {
$(".wpforo-profile-home .wpf-field-type-url a[href^='http']").attr('target','_blank');
});
</script>
<?php } );
either via How to Easily Add Custom Code in WordPress (without Breaking Your Site)
or in the functions.php of your WP theme
replace " _blank " with the target you want
I used snippets plugin and activated the above code, but it didn't work.
The target link has not changed.
I don't know if I missed anything, but I followed the steps as described.
More specific:
The current link of "Shop account" button in user profile is 'https://mysite.com/my-account/' and I would like to change it to: 'https://mysite.com/myshop/'
Thank you again for your time.
Hello again, anyone that may suggest a solution?
The button is in "wpf-pp-menu-item".
I have attached an image indicating the button to which I am referring to for better understanding.
Thank you.
Open the shop link with the browser inspector and search for the css class from the shop url
Example the css class from code above
wpf-field-type-url
https://www.screencast.com/t/UU0ZsvLh
add_action( 'wp_head', function () { ?>
<script>
jQuery(document).ready(function($) {
$(".wpforo-profile-wrap .your-shop-url-class a[href^='http']").attr('target','_blank');
});
</script>
<?php } );
and replaced "your-shop-url-class" with the class from the shop link
The class id that I got is :
a class="wpf-pp-menu-item" href="https://mysite/my-account/"
So the code will be (correct me if I am wrong):
add_action( 'wp_head', function () { ?>
<script>
jQuery(document).ready(function($) {
$(".wpforo-profile-wrap .wpf-pp-menu-item a[href^='http']").attr('target','_blank');
});
</script>
<?php } );
?
remove the "a" tag
add_action( 'wp_head', function () { ?>
<script>
jQuery(document).ready(function($) {
$(".wpforo-profile-wrap .wpf-pp-menu-item[href^='http']").attr('target','_blank');
});
</script>
<?php } );
I think I am missing something, or I am asking the wrong question.
The link did not change.
I reinspected the element and get this:
a class="wpf-pp-menu-item" href="https://mysite.com/my-account/" target="https://myshop.com/myshop/"
When I press the button it still links to "my-account", and not to "myshop"
Should I change the code 'target' to 'href' or something?
Thank you for your patience.
Posted by: @sn21Is there a way to change the target link of the “Shop account”
you don't want change the target of the link
The target attribute specifies where to open the linked url.
and don't change the link itself
you have to change the link to the shop where you created it 😉
Thank you very much Tutrix, but if you mean to change the hyperlink of the page, unfortunately this is not an option me.
I need to change the linked url of the button as you correctly said.
I am sorry for any misunderstanding.
where did you create the menu item "shop account"?
there you have to enter the correct link to the shop
do not change anything else, just this only one menu item
Actually, I did not create it (i wouldn't know how 😊 ).
It was already there, after installing wPForo plugin. 🙂
There is no option to change the shop account UR, it's added automatically when it detects WooCommerce installation, it refers you to WooCommerce profile page. And the question is why do you want to change the URL? If you don't want your users to go to their customer account page then just disable this button by a small CSS code.
Hi Robert and thank you for your reply.
I have a different shop account page for each user role.
Actually, disabling it would be most helpful!..
Could anyone help with the CSS for disable?
Here are the CSS codes to hide all kind of profile header buttons: https://wpforo.com/community/how-to-and-troubleshooting-2/can-not-access-to-button-message/#post-29642
-
How can individuals be sent to a custom URL when they click on one of the forums?
4 years ago
-
Problem with the topic titles and its links
6 years ago
-
How to hide or change shop account icon?
6 years ago
-
How to make links underlined automatically?
6 years ago
-
post a link image
7 years ago
- 19 Forums
- 14.2 K Topics
- 71.2 K Posts
- 32 Online
- 6,035 Members
