Modify Virtuemart User Account Maintenance URL and page name.

Issue: user account maintenant pages are targeted by spammer to create fake account on your site.

To mitigate this issue on top of a solid firewall, you can change the default URL and page name so that the crawler won’t be able to automatically find it.

Solution:

1-Edit or create a menu item for the Virtuemart USer Account Maintenance page if you didn’t have one previously

2-Set the page title and the alias to whatever you think is more suitable. You might for instance localize the string.

How to prevent home page modules to show on virtuemart search results page?

Issue: Home page modules show on virtuemart search result pages, which in some cases might not be desirable.

Solution: The solution that is widely found searching on the internet is that you need to create a menu item for the search module. If you do so, and use the virtuemart search module, this should not give any results. The missing step is that you need to create an overwrite for your virtuemart seach module and edit it. In the search form action, replace index.php by “search” or whatever you set the search menu item alias to be.

In short:

1- Create menu item for joomla search

When selecting the menu item type, select “Search Form or Search Results”
Note the alias for the page, as you will need it at a later step.

2-In your templates customization page, create an override for the mod_virtuemart_search default.php file:

3- Open the override you created and modify the route to point it to the newly created search page:

JRoute::_ ('index.php?option=com_virtuemart&view=category&limitstart=0', FALSE);
JRoute::_ ('search?option=com_virtuemart&view=category&limitstart=0', FALSE);

4- Control where the modules are displayed as usual.

Login with Facebook in Laravel 5.8

To add social media login functionality to Laravel 5.8, one library come over and over again, it’s socialite.

https://github.com/laravel/socialite

SSH into your server and run the following command in the directory where your Laravel is installed:

composer require laravel/socialite

As composer is locked after install. I needed to reinstall completely. On my host, the installation needs to be global for it to work (or at least, a local install did not do the trick). So I ran

composer global remove laravel/installer
composer global require laravel/installer laravel/socialite
cd Path/to/my/directory
laravel new ProjectName --auth

without global, laravel was an unknown command.

Official documentation can be found on the Laravel website:

https://laravel.com/docs/6.x/socialite

Additional resources:

https://medium.com/@confidenceiyke/laravel-5-8-facebook-socialite-authentication-8863b9a43f11

https://getcomposer.org/doc/01-basic-usage.md

https://getcomposer.org/doc/03-cli.md

https://getcomposer.org/doc/01-basic-usage.md

Add google Recaptcha control on login form in Laravel

To implement Google Recaptcha in Laravel check our article on implementing Google Recaptcha for Laravel registration.

in /app/Http/Controllers/Auth/LoginController.php

Add the following lines:

use Illuminate\Http\Request;
use App\Rules\GoogleRecaptcha;

And before theclosing curly brackets:

/** 
* Validate the user login request. 
* 
* @param  \Illuminate\Http\Request  $request 
* @return void 
*/ 
protected function validateLogin(Request $request) 
{ 
    $this->validate($request, [ 
    $this->username() => 'required|string', 
    'password' => 'required|string', 
    'g-recaptcha-response' => ['required', new GoogleRecaptcha], 
    ]); 
}

Login with user name instead of email in Laravel

Default laravel login is set to work with email and password but there might be some instance where login with an email address is not desirable and you might want to change this to login with a username.

The advantage of logging in with an email address is that you can be sure it will be unique. The drawback is that it is a bit long to type and some people are not comfortable giving their email address, so depending on your type of application, where having the email address is not essential, it makes sense to offer to login with a username instead.

In Laravel 5.8

Add the following function in app/Http/Controllers/Auth/LoginController.php

/**
*Use username instead of default (email address)
*for authentication
**/
public function username(){
    return ('name');
}

in the return(‘name’) statement, ‘name’ stand for the column name in your user table in your database you want to use. In my case the column is ‘name’.

in resources/views/auth/login.blade.php change the email login field with a username field as follow:

<div class="form-group row">
    <label for="name" class="col-md-4 col-form-label text-md-right">{{ __('Name') }}</label>
    <div class="col-md-6">
       <input id="name" type="text" class="form-control" name="name" required>
  </div>
</div>

As you are now using the username instead of the email for logging in, you need to make sure the username is the unique. To do that you will need to modify your migrations file for create_users_table.php

table->string('name')->unique(); 

And you are all set.

Price Filter not working

Issue: the woocommerce price filter is not working.

Solution: The issue is likely due to a compatibility issue with your theme. To solve that, you will need to declare the theme woocommerce support and copy your page.php file content to a new file that you will call woocommerce.php. You will replace the loop by <?php woocommerce_content(); ?>.

You will also need to make sure woocommerce support is declared in your theme functions.php: add_theme_support( 'woocommerce' );

For more info on woocommerce theme development and support:

Integrate woocommerce in your theme

Sidebar not showing on product tag pages

Issue: The sidebar and by extension the sidebar widgets are not showing on your product tag page on your woocommerce site.

Solution: While investigating this issue I have come accross many suggestion to use the widget-logic plugin to solve this issue. Chances are that it won’t help as some code is preventing your sidebar to show on the product_tag page.

Check your page.php template. It might have condition checking if the page is a woocomerce category page or the shop page for better control .

Check if your template has a woocommerce.php file, if it doesn’t look for the page.php file.

Check for a condition such as

if (is_product_category()||is_shop() )

Check that this control the display of the sidebar for example you might see:

get_sidebar()

If you find that the condition checking the page type call the sidebar, bingo, just add an extra condition so that the same code apply to your product-tag pages:

is_product_tag()

If you need to adapt the display for certain tag only you can use:

is_product_tag('tag_name')

To summarize in case you have condition controlling the call to the sidebar make sure to add the is_product_tag() function. In our example it would look like this:

 if (is_product_category()||is_shop() ||  is_product_tag()  )

What is the question mark in the middle of a php expression?

The question mark in the middle of a php expression is a shorthand for a conditional statement and comes together with a column. Together they form a ternary operator.

isset($x)? $y:$z

It evaluates to $y if isset($x) is true and to $z if it is false. Note that isset($x) can be any function method or variable returning a boolean.

Add shortcode with WordPress new content editor interface Gutenberg

You might have add difficulties to and errors when trying to add shortcode to new WordPress articles and posts.

To add a short code in the new editor, hover at the top center of an unactive block and click on the circled + icon that appears at its top center .

Adding a block above another one.

You can also click on the circled + icon at the top left corner of the page.

In the search bar type: shortcode

Click on the shortcode option. A new block will be added.

The shortcode block can be found under widgets in the block type selection box.

Type in your shortcode as you would do in the classic view:

[ShortCodeTag]

Note: I did encounter an error that the page couldn’t be saved when trying to save the page with the square brackets in WordPress 5.2.4. It turned out that the page was actually saved. This issue was supposed to be fixed already since 3.9 see github repo for wordpress gutenberg.