Advanced Custom Fields and Woocommerce Location Rules

Just a short post about a Git I’ve started up. I recently needed to specify a couple of ACF fields to only appear on a ‘Simple Product’ type in ever popular Woocommerce. To my surprise there wasn’t an existing plugin that extended ACF location rules to integrate with Woo attributes. So I went about writing my very own. Recently deciding I wanted to give more back to the community that gives so much to me I stuck it up of Github.

I will continue to add attributes over the next few weeks. At the time of writing this post I currently have support for the following attributes.

  • Product Types (Simple, Grouped, External, Variable)
  • Product Variations (Downloadable, Virtual, Sold Individually)
  • Product Taxation (Product Taxable, Shipping Taxable)

Please download and comment on the Git should you find any issues. Also please make suggestions for additional features in the issues area.


Creating administrator user in WordPress with only FTP details (Updated)

I seem to have recently gained a number of clients who were very keen for work to be completed due to bad communication with their previous developers. This usually meant that anything they’d ask for wouldn’t be received for some time. This raises a dilemma in that these clients almost always don’t have all the login info you need.

Today I wanted to grab a backup of a site and all I had was the sites FTP and the clients WP login with insufficient privileges to manage plugins. Easy enough to solve with the little snippet below.

    require('wp-load.php' );
    $username = "my_admin";
    $password = "StrangePassword123!";
    $email = "[email protected]";
 	// create user and return new user id
 	$id = wp_create_user($username, $password, $email);
 	// check create for WordPress error
    if(!is_wp_error($id)) {
    	// update users role to admin - this can't be done on the create
        wp_update_user( array ('ID' => $id, 'role' => 'administrator'));
        print 'User successfully created';
    else {
    	// print WordPress error
    	print $id->get_error_message();

Just fill in your user, pass and email and you’ll be set. You’ll also have to changed the path to wp-load.php depending on where you place this script. Also as a good safety measure don’t forget to delete it when you’re done.

Created myself and user and backed up using BackupBuddy. Easy.

Updated: I updated the code to give more useful error messages.