Call   0208 3131682   Mon-Fri 9am-6pm
All Posts By

louie171

Buddypress – How to add group types

By | Buddypress, PHP, Wordpress | No Comments

It can be useful to have group types sometimes for example, maybe a University might want to have 2 group types for staff and students. So they could have staff groups and student groups ( and a directory for each eg staff would list the staff groups and student groups would list the Student Groups ).

This is easy todo in Buddypress:

 

you can then have links like this to view the group directory:

 

/groups/type/staff/

/groups/type/students/

SQL for use in migrating a Drupal website to WordPress

By | Drupal, Drupal to Wordpress Migration, SQL | No Comments

Currently I’m working on migrating a Drupal 7 website to WordPress, in the process I’ve learned alot about the Drupal database schema. So this post is a place for me to store handy queries and notes. Its a Work in Progress so I’ll add more over the coming weeks.

Content types in Drupal are similar to post types in WordPress where fields can be added, however in the database how the fields are handled is very different from WordPress. In Drupal fields are added as separate tables.

SQL to get multiple images ( stored as a collection item field in Drupal)

The field is called field_images stored in the table field_data_field_images table. Because the field is collection there is only 1 value stored in the field_data_field_images table ( the collection id). To get the individual items of the collection (images in this case), we need to join to file usage table on that id then to file_managed table on the fid. Then we have the information about the images ( filenames etc ).

select n.nid, n.title,  m.* from node n
left join field_data_field_images f on n.nid = f.entity_id
left join file_usage u on f.field_images_value = u.id
left join file_managed m on u.fid = m.fid
where n.nid = node_id

Get all fields on a content_type 

eg for content type ‘bobs_tyre’

SELECT field_name FROM field_config_instance ci WHERE ci.bundle = ‘bobs_tyre’

 

Why link your website to your CRM

By | Customer Relationship Management - CRM, Forms, HubSpot, Marketing Automation, Web Design, Wordpress | No Comments

This post runs over why you would connect a CRM (Customer Relationship Management) system ( such as Hubspot) to your website.

Many CRMs now allow you to capture form data on your website and pull this into the CRM, this has the following benefits to you:

  • store users information in your CRM
  • be able to follow up in CRM and have all the interactions in CRM so you can see the history of interactions with that person
  • see what the user has been looking at on your website

 

Hubspot WordPress form integration

The are 2 main ways of taking the users details from your website:

  • a form (standard or popup)
  • a chat box

An example form might look something like above ( this is one I’ve generated in Hubspot , but you can customise and generate your own forms in many ways in Hubspot, manually with HTML or with a tool such as Gravity forms for WordPress, or with other tools). Also remember to make sure you are GDPR compliant if your in the EU.

When the user submits the above form, this is what is will look like in Hubspot.

Hubspot captured lead from WordPress website

 

As you can see the data from the form is recorded in the activity section above and a new contact (Beavis) has been generated in the CRM contacts database. Where you can record all your interactions with this contact ( email , phone and so on ). Emails can also be automatically logged into your CRM and you can automate replies to emails with Marketing Automation sequences. This can be very useful when you have a large number of users (for example your supporters contacting your Charity or Not for Profit Organisation).

I’ve been using Hubspot in this article but the same can be done with others such as Salesforce ( and many others ). I haven’t gone into much technical detail in this post, only why and what are the benefits of this.

CRMs are great for following up and interacting with your supporters, customers, leads and so on. I hope I’ve shown you how you can easily ( and automatically ) put form contacts from your website into your chosen CRM, to make this process easy and save you time.

I plan to write another article on the technical aspects of how todo, what I’ve described briefly ( integrate your WordPress website with a CRM like Hubspot)  in the coming months, but if you’d like help with doing this then please contact us below.

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