Wordpress: On specific url the admin toolbar shows up (Even when not logged in) - wordpress

I'm running into a Major trouble.
Today I found out that when visiting a specific URL on my website, the admin toolbar shows up. Also for people who are not logged in. It appears that the visitor is logged in, but that's not true. All the links in the toolbar go to a 404 page. However, important information is being shown, like how many plugins need an update and even my login name.
Is anyone familiar with this?
Since it is a corporate website, I need a fix as soon as possible.
(due to security reasons I won't post the exact url in public)
Hopefully anyone can help me.
Thanks,
Stefan

Try to add either of these code in functions.php of your theme,
Code 1:
<?php
add_filter('show_admin_bar', '__return_false');
?>
Code 2:
function hide_admin_bar_from_front_end(){
remove_action( 'wp_head', '_admin_bar_bump_cb' );
return false;
}
add_filter( 'show_admin_bar', 'hide_admin_bar_from_front_end' );

Related

How can I display Product Images to Logged In Users only, with Logged Out Users seeing an alternative image?

I would like to modify my WordPress/WooCommerce website, so that my Product Images have the following conditions:
Logged in site visitors:
I would like logged in visitors, to be able to see all of the WooCommerce Product Images.
Logged out site visitors:
I would like logged out visitors, to see an alternative image. Therefore, hide the Product Image. This alternative image, will be the same for every Product.
Firstly, you are going to need to create a Child Theme, for your WordPress/WooCommerce website.
Once created, simply insert the following code, into the functions.php file, within your Child Theme:
<?php
// Remove Default WooCommerce Product Images/Placeholders.
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
// Create conditional logic function.
function logged_in_images(){
// If site visitor is Logged in, display Default WooCommerce Product Images/Placeholder.
if ( is_user_logged_in() ) {
echo woocommerce_show_product_images();
}
// If site visitor is not logged in, display the following Image instead.
else {
echo '<img src=http://vaporcenter.be/theme/Wholesale/img/placeholders/default.jpg?1504084579>';
};
}
// We are inserting ('Hooking' into) the above function into where the Default WooCommerce Product Image/Placeholder was, before we removed it.
add_action( 'woocommerce_before_single_product_summary', 'logged_in_images', 20 );
?>
Be sure to replace http://vaporcenter.be/theme/Wholesale/img/placeholders/default.jpg?1504084579 with your desired image.
Don't forget, you can remove the comments (// ...) from the code. They are there, to just help explain what is happening.
I have tested the above code and it does work.
Best of luck!
If you receive an error
Step One: Using an FTP client, such as Filezilla, go into your Root Folder (Where you installed WordPress).
Look for a file entitled wp-config.php and drag this to your computer.
Open the file, using Notepad/Notepad++ and look for the line define('WP_DEBUG', false); and change 'false' to 'true'.
Drag the wp-config.php file back from where you got it from.
Refresh the page you are having an issue. You should then see an error message, which will be helpful in addressing how to resolve any issues.
Once you have resolved your issue, and your website is back in working order, head back into your wp-config.php and change 'true' back to 'false'.

Avoid displaying the share buttons in the post contained in my home page

I am creating a website using the Candidate theme in wordpress.
There are a number of posts in my website. My home page is set to show the most recent five posts in it.
I have used a plugin named as 'Share This' to show the share buttons for facebook, twitter and google+ just above the contents of my posts. The buttons got displayed above the contents of the posts. Now the problem arose when the buttons got displayed in my home page too where the recent posts along with a short summary is displayed.
This started looking quite mess. I tried a lot to remove these but couldn't.
While researching for this, in some wordpress support forums, i found that the following codes may work
remove_filter( 'get_the_excerpt', 'st_remove_st_add_link', 9 );
remove_filter( 'the_excerpt', 'st_add_widget' );
This did no chage. And I used the following code too
function remove_sharethis() {
if ( ! is_singular( array( 'post', 'page' ) ) ) {
remove_filter('the_content', 'st_add_widget');
remove_filter('the_excerpt', 'st_add_widget');
remove_action('wp_head', 'st_widget_head');
}
}
add_action( 'template_redirect', 'remove_sharethis' );
Is there any way to do so??
I need help desperately.
And even the buttons are not seen completely. They are seen cut-off.
And there is one more problem in this. If I try sharing the posts through facebook share button of this plugin, the contents of the posts donot load at the share screen. Rather it just shows the website's name.
Please help me if there is someone who has better knowledge in this sort of problems and this plugin.
Simple solution, you could use CSS to hide the share buttons from your home page.
Will help if you can share a link to the homepage
The AddThis plugin author responds with specific help to postings here.
HTH

Wordpress Job Manager Pagination Issue

I am using the Wordpress Jobs Manager plugin. It all works great except the pagination feature. When enabled, the pagination buttons just redirect the user to the homepage instead of to the paginated page of results. As far as i can tell this is a problem with permalinks but i wondered if anyone had a workaround as i cannot use the standard permalinks on my site.
Does anyone know of any possible fixes? Its a custom built theme.
Thanks for you help guys
I know its a long time since you posted, but i had this issue today and came across your post.
I did some investigating and found it to be a problem with the way wordpress was dealing with the rewrites for canonical redirects.
I did a search on the internet and found the following post on wordpress.stackexchange.com by Celine Garel which deals with this situation for custom post types, i just changed it to work with a page.
https://wordpress.stackexchange.com/questions/134339/pagination-on-custom-post-type-not-working-if-permalinks-set-to-rewrite-url
Add this to your themes function file,
add_filter( 'redirect_canonical','custom_disable_redirect_canonical' );
function custom_disable_redirect_canonical( $redirect_url ){
if ( is_page('Your_job_list_page') ) $redirect_url = false;
return $redirect_url;
}
This fixed it for me. Hope it helps you or anybody else.

Hide Wordpress dashboard?

I'm new to wordpress and a bit confused with something. I'm trying to build a classified marketplace type of website for myself. I am NOT building this for a "client". I will probably be using a hack of several different plugins as my coding skills are not up to par. Eventually I will hopefully have lots of users who will be composed of buyers & sellers.
My question pertains to the WP dashboard. When buyers/sellers sign up for my site, will they be able to see the backend WP dashboard? I would prefer that they NOT be able to access a backend dashboard at all let alone a WP branded one. Is this possible? If so any clue as to how this might be accomplished?
thank you Brian
Normal users do not actually see the 'backend' WP dashboard. What they are seeing is a 'profile' type page meant for the original functionality of wordpres; being a blog.
If you do not want users to go to this page when they log-in, you can use a couple of hooks. Here is some code that redirects to the front page after logging-in and logging-out. This goes in your functions.php file.
add_action('login_form', 'ang_redirect_to_front_page');
add_action('wp_logout', 'go_home');
function ang_redirect_to_front_page() {
global $redirect_to;
if (!isset($_GET['redirect_to'])) {
$redirect_to = get_option('siteurl');
}
}
function go_home(){
wp_redirect( home_url() );
exit();
}
And, if your theme is still displaying the menu at the top of the screen that allows the users to go to this 'profile' area, you can go into your footer.php file and remove this:
<?php wp_footer();?>
However, if you do this, then you will not see it as the admin either.
WordPress is might not be the thing to use for that kind of website, even with a bunch of plugins. Read up on other content management systems just incase.
This link might answer your question:
http://buddypress.org/support/topic/how-to-prevent-non-admins-from-accessing-wp-admin-dashboard/
You can also add this to your theme's function.php file:
// DISABLE ADMIN BAR FOR ALL USERS
show_admin_bar( false );
If you are not too used to wordpress, use WOOCOMMERCE plugin. Its completely free and well documented

WooCommerce Show Payment Gateways for Logged In Customers Only

I am setting up an ecommerce site using Wordpress and WooCommerce. We are using the wordpress member accounts to track customer information, and we need a way for logged in members only to be able to choose to purchase their cart "on credit", meaning no payment is required to place the order. Basically what I have done is hi-jacked the "Check" option (since we don't need it anywhere else) and renamed it "Credit" since it allows for the functionality we need.
However, I need a way for the "Credit" (check) option to only display if the user is logged in. Is there any way I can just "unhook" this option if the user isn't logged in? This seems like something that would be easy to do, but I couldn't find anything about it. Any help is appreciated.
The original answer to this question (from BWDesign) no longer works due to changes in WooCommerce (at least from WooCommerce 2.1.7 onwards, possibly before). This does the trick now (tested on 2.1.7 and 2.1.8), add it to e.g. your functions.php file:
add_filter( "woocommerce_available_payment_gateways", "rp_filter_gateways", 9999 );
function rp_filter_gateways($args) {
if(!is_user_logged_in() && isset($args['cheque'])) {
unset($args['cheque']);
}
return $args;
}
I just found the solution. In the class-wc-cheque.php file, the check or "cheque" (crazy brits) option is hooked using add_filter('woocommerce_payment_gateways', 'add_cheque_gateway' );. So the solution was simply to add this code to my functions.php file:
if(!is_user_logged_in()){
remove_filter('woocommerce_payment_gateways', 'add_cheque_gateway' );
}
Hope this helps!

Resources