Buddypress cheat sheet

By | Uncategorized | No Comments

in Member loop / directory – show xprofile fields

Just find the field in wp-admin and pop into the function above and echo it.

 

Buddypress how to sort Groups page alphabetically by default

By | Buddypress, PHP, Wordpress | No Comments

In this short blog post I’ll run over how you can sort the Groups index page in Buddypress alphabetically by default (i.e. on first load of page they will be ordered by group name).

Edit or override 2 of the Buddypress templates

You’ll need these in your theme:

wp-content/YOUR_THEMENAME/buddypress/groups/index.php

and

wp-content/YOUR_THEMENAME/buddypress/groups/groups-loop.php

If these templates don’t exist in your theme you’ll need to make copies of the 2 templates from the Buddypress plugin  ( find in buddypress/bp-templates/bp-legacy/buddypress ) and pop into your theme directory in a folder called buddypress. You might need to copy from your parent theme if they are used there ( this is because of the buddypress / wordpress template hierachy – you can look that up if you don’t understand this).

 

Changes in groups-loop buddypress template

Before the bp_has_groups function call you need to add:

and then change the bp_has_groups function to:

 

Changes in index groups template

find this section and change to have alphabetical first ( you could also use the selected attribute ):

 

And thats it job done. Remember Buddypress can save your select choices in the session, which can be confusing – so clearing the cache will help in this scenario.

 

 

 

Laravel ajax calls failing with response code 419

By | Ajax, Laravel, PHP | No Comments

Recently I was working on a Laravel application with some ajax, and I was getting a 419 error after firing an Ajax call to a Laravel controller.

Laravel requires a token to be sent on some types of requests (POST being one of them), this is to prevent Cross site request forgery ( e.g. a form being submitted from somewhere it was intended by the developer to be submitted from ).

In php files its very easy to add this with the function call csrf_field().

But in js files, we need to essentially pull in this you store the token somewhere on the page and use js to pull it in.

you can pop the token in the page somewhere like this:

 

for reference: https://laravel.com/docs/5.5/csrf

 

 

 

 

Laravel how to set a checkbox value to checked based on models value

By | Laravel, PHP | No Comments

In this post I’ll show how to set a Laravel checkbox value to checked based on the value stored on the model.

In this example I’ll be using the Laravel Collective Form checkbox

In the code example above my checkbox is called ‘collected’ the value when checked is ‘yes’ , I wanted to populate my form with the value from the database stored on the model (which is yes or no on the $gas_cert->collected field of the model), the Form::checkbox wants a boolean to decide whether to check the checkbox or not.

I want the form to take either the last input to the collected input or the value in the database (ie if yes check the checkbox).

If I did want to just take into account the model value it could be simplified to this:

 

 

 

How to override the comments form in a child theme

By | Custom Wordpress Theme Development, PHP, Programming, Theming, Wordpress | No Comments

This is a quick post on how to provide your own comments template in your child theme ( overriding comments.php in your parent theme). You can just as easily use the same code to override comments.php if you aren’t using a child theme.

Todo this you need to you need to use the filter ‘comments_template’ ( see the wordpress codex on this filter here)

 

A handy thing you might sometimes want todo is to have a custom comments template, for various custom post types. If you did want todo this you could just add in an if to encase the returned path and filename. e.g.

 

 

Hope someone finds these snippets for how to override comments.php useful.

 

 

How to engage your staff using your Intranet

By | Buddypress, Intranet, PHP, Web Design, Wordpress | No Comments

In this article, we’ll look at some ideas for useful things to have on your intranet and how to use these to help engage your Employees, members or Volunteers.

intranet employee engagement features

What are the benefits of engaged staff ?

  • Happy workforce ( productive workforce, helps business be more profitable)
  • Low Staff turnover ( saves money in recruitment and training)

Useful Intranet features  for employee engagement

Employee Recognition Section

Make your staff feel engaged by recognising them and their achievements ( both personal and professional ). A section on your homepage for this would really make people feel valued, and a good way for other employees to spark up a conversation with the recognised individual ( or team) Some ideas of the kind of thing to recognise:

  • An employee has a work anniversary
  • An employee is doing a Marathon for charity
  • A employee or team have delivered a great project that will help company save money
  • The works Football team are doing well

“Our Intranet features a news feed with stories of employee honors and work anniversaries, volunteering, company sponsorships and other news with links to more details. It can be a challenge sharing our culture across four states in a regulated industry. But people love reading about and seeing images of colleagues they know as well as those they’ve never met. By far we’ve gotten the most engagement posting photos of employees in Halloween costumes and celebrating Ugly Sweater Day. In a regulated industry, the simple, silly things unite us and we laugh together. ” – An Intranet Manager I interviewed that wishes to remain anonymous.

 

New Employees Section

Welcome your new employees, with a section on the homepage, linking to their staff profiles.

Suggestions

Have somewhere, that employees can easily post suggestions, to save money, to make staff more engaged, to make money and so on. Your staff are your businesses greatest asset ( often the ones on the shop floor close to certain areas of the business can deliver great insights – that might otherwise never come to light). You could incentivise with a monthly prize for the best suggestion.

Personalisation

Display relevant content to the Intranet visitor based on one or a number of criteria ( or even let users pick what they want to see).

Displaying content based on a Persona 

E.g. one type of persona could be ‘New Starter’ , are there any important documents they need to read, are their specific forms they might need to fill ( eg bank details so they can get paid on time).

If your a large organisation (with multiple locations across the globe) you might want display things based on the location, or the team ( maybe HR need to see something different to IT and so on).

Allowing Users to pick content they are interested in

You can let users pick some of the content they are interested in and have it displayed prominently for them.

 

Are you looking to have an intranet developed or would like to upgrade / improve your existing Intranet ? Get in touch we’re experts in this area.