Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Cannot figure it out Parse Error functions.php

Discussion in 'Misc WordPress Requests' started by inked_koi, Mar 22, 2018.

  1. inked_koi

    Guest

    Cannot figure it out Parse Error functions.php, by inked_koi

    Tonight I ran into a parse error within in functions.php. I can’t seem to figure out how to correct it. I’ve tried adding ?> at the very end, added open_tag to my php.ini.
    I even uploaded the code to the php code checker, which returned no errors.

    Please help me.

    <?php

    function child_styles() {
    wp_enqueue_style( 'my-child-theme-style', get_stylesheet_directory_uri() . '/style.css', array('front-all'), false, 'all' );
    }
    add_action('wp_enqueue_scripts', 'child_styles', 11);

    /*
    Plugin Name: Restrict Content Pro - Custom User Fields
    Description: Illustrates how to add custom user fields to the Restrict Content Pro registration form that can also be edited by the site admins
    Version: 1.0
    Author: Pippin Williamson
    Author URI: http://pippinsplugins.com
    Contributors: mordauk
    */

    /**
    * Adds the custom fields to the registration form and profile editor
    *
    */
    function pw_rcp_add_user_fields() {


    $address = get_user_meta( get_current_user_id(), 'rcp_address', true );
    $city = get_user_meta( get_current_user_id(), 'rcp_city', true );
    $province = get_user_meta( get_current_user_id(), 'rcp_province', true );
    $postal_code = get_user_meta( get_current_user_id(), 'rcp_postal code', true );
    $home_phone = get_user_meta( get_current_user_id(), 'rcp_home phone', true );
    $business_name = get_user_meta( get_current_user_id(), 'rcp_business name', true );
    $business_address = get_user_meta( get_current_user_id(), 'rcp_business address', true );
    $business_city = get_user_meta( get_current_user_id(), 'rcp_business phone', true );
    $business_postal_code = get_user_meta( get_current_user_id(), 'rcp_business phone', true );
    $business_phone = get_user_meta( get_current_user_id(), 'rcp_business phone', true );
    $rmt_number = get_user_meta( get_current_user_id(), 'rcp_rmt number', true );
    ?>

    <p>
    <label for="rcp_address"><?php _e( 'Home Address', 'rcp' ); ?></label>
    <input name="rcp_address" id="rcp_address" type="text" value="<?php echo esc_attr( $address ); ?>"/>
    </p>
    <p>
    <label for="rcp_city"><?php _e( 'City', 'rcp' ); ?></label>
    <input name="rcp_city" id="rcp_city" type="text" value="<?php echo esc_attr( $city ); ?>"/>
    </p>

    <p>
    <label for="rcp_province"><?php _e( 'Province', 'rcp'); ?></label>
    <input name="rcp_province" id="rcp_province" placeholder="Province" type="text" value="<?php echo esc_attr( $province ); ?>"/>
    </p>
    <p>
    <label for="rcp_postal_code"><?php _e( 'Postal Code', 'rcp'); ?></label>
    <input name="rcp_postal_code" id="rcp_postal_code" type="text" placeholder="Postal Code" value="<?php echo esc_attr( $postal_code); ?>"/>
    </p>
    <p>
    <label for="rcp_home_phone"><?php _e( 'Home Phone','rcp' ); ?></label>
    <input name="rcp_home_phone" id="rcp_home_phone" type="text" placeholder="Home Phone" value="<?php echo esc_attr( $home_phone); ?>"/>
    </p>

    <hr>
    <br>
    <p>
    <label for="rcp_business_name"><?php _e( 'Business Name', 'rcp' ); ?></label>
    <input name="rcp_business_name" id="rcp_business_name" type="text" placeholder="Business Name" value="<?php echo esc_attr( $business_name); ?>"/>
    </p>
    <p>
    <label for="business_address"><?php _e( 'Business Address', 'rcp' ); ?></label>
    <input name="business_address" id="rcp_business_address" type="text" placeholder="Business Address" value="<?php echo esc_attr( $business_address ); ?>"/>
    </p>
    <p>
    <label for="rcp_business_city"><?php _e( 'Business City', 'rcp' ); ?></label>
    <input name="rcp_business_city" id="rcp_business_city" type="text" placeholder="Business City" value="<?php echo esc_attr( $business_city); ?>"/>
    </p>
    <p>
    <label for="rcp_business_postal_code"><?php _e( 'Business Postal Code', 'rcp' ); ?></label>
    <input name="rcp_business_postal_code" id="rcp_business_postal_code" placeholder="Business Postal Code" type="text" value="<?php echo esc_attr( $business_postal_code); ?>"/>
    </p>
    <p>
    <label for="rcp_usiness_phone"><?php _e( 'Business Phone', 'rcp' ); ?></label>
    <input name="rcp_business_phone" id="rcp_business_phone" type="text" placeholder="Business Phone" value="<?php echo esc_attr( $business_phone); ?>"/>
    </p>

    <?php
    }
    add_action( 'rcp_after_password_registration_field', 'pw_rcp_add_user_fields' );
    add_action( 'rcp_profile_editor_after', 'pw_rcp_add_user_fields' );

    /**
    * Adds the custom fields to the member edit screen
    *
    */
    function pw_rcp_add_member_edit_fields( $user_id = 0 ) {

    $address = get_user_meta( $user_id, 'rcp_address', true );
    $city = get_user_meta( $user_id, 'rcp_city', true );
    $province = get_user_meta( $user_id, 'rcp_province', true );
    $postal_code = get_user_meta( $user_id, 'rcp_postal_code', true );
    $home_phone = get_user_meta( $user_id, 'rcp_home_phone', true );
    $business_name = get_user_meta( $user_id, 'rcp_business_name', true );
    $business_address = get_user_meta( $user_id, 'rcp_business_address', true );
    $business_city = get_user_meta( $user_id, 'rcp_business_city', true );
    $business_postal_code = get_user_meta( $user_id, 'rcp_business_postal_code', true );
    $business_phone = get_user_meta( $user_id, 'rcp_business_phone', true );
    $rmt_number = get_user_meta( $user_id, 'rcp_rmt_number', true );

    ?>
    <tr valign="top">
    <th scope="row" valign="top">
    <label for="rcp_address"><?php _e( 'Address', 'rcp' ); ?></label>
    </th>
    <td>
    <input name="rcp_address" id="rcp_address" type="text" value="<?php echo esc_attr( $address ); ?>"/>
    <p class="description"><?php _e( 'The member\'s home address', 'rcp' ); ?></p>
    </td>
    </tr>
    <tr valign="top">
    <th scope="row" valign="top">
    <label for="rcp_city"><?php _e( 'City', 'rcp' ); ?></label>
    </th>
    <td>
    <input name="rcp_city" id="rcp_city" type="text" value="<?php echo esc_attr( $city ); ?>"/>
    <p class="description"><?php _e( 'The member\'s city', 'rcp' ); ?></p>
    </td>
    </tr>
    <tr valign="top">
    <th scope="row" valign="top">
    <label for="rcp_province"><?php _e( 'Province', 'rcp' ); ?></label>
    </th>
    <td>
    <input name="rcp_province" id="rcp_province" type="text" value="<?php echo esc_attr( $province ); ?>"/>
    <p class="description"><?php _e( 'The member\'s province', 'rcp' ); ?></p>
    </td>
    </tr>
    <tr valign="top">
    <th scope="row" valign="top">
    <label for="rcp_postal code"><?php _e( 'Postal code', 'rcp' ); ?></label>
    </th>
    <td>
    <input name="rcp_postal code" id="rcp_postal_code" type="text" value="<?php echo esc_attr( $postal_code ); ?>"/>
    <p class="description"><?php _e( 'The member\'s postal code', 'rcp' ); ?></p>
    </td>
    </tr>
    <tr valign="top">
    <th scope="row" valign="top">
    <label for="rcp_home_phone"><?php _e( 'Home Phone', 'rcp' ); ?></label>
    </th>
    <td>
    <input name="rcp_home_phone" id="rcp_postal_code" type="text" value="<?php echo esc_attr( $home_phone ); ?>"/>
    <p class="description"><?php _e( 'The member\'s home phone', 'rcp' ); ?></p>
    </td>
    </tr>
    <tr valign="top">
    <th scope="row" valign="top">
    <label for="rcp_rmt_number"><?php _e( 'RMT Number', 'rcp' ); ?></label>
    </th>
    <td>
    <input name="rcp_rmt_number" id="rcp_rmt_number" type="text" value="<?php echo esc_attr( $rmt_number ); ?>"/>
    <p class="description"><?php _e( 'The member\'s rmt number', 'rcp' ); ?></p>
    </td>
    </tr>
    <hr>
    <tr valign="top">
    <th scope="row" valign="top">
    <label for="rcp_business_name"><?php _e( 'Business Name', 'rcp' ); ?></label>
    </th>
    <td>
    <input name="rcp_business_name" id="rcp_business_name" type="text" value="<?php echo esc_attr( $business_name ); ?>"/>
    <p class="description"><?php _e( 'The member\'s business name', 'rcp' ); ?></p>
    </td>
    </tr>
    <tr valign="top">
    <th scope="row" valign="top">
    <label for="rcp_business_address"><?php _e( 'Business Address', 'rcp' ); ?></label>
    </th>
    <td>
    <input name="rcp_business_address" id="rcp_business_address" type="text" value="<?php echo esc_attr( $business_address ); ?>"/>
    <p class="description"><?php _e( 'The member\'s business addresss', 'rcp' ); ?></p>
    </td>
    </tr>
    <tr valign="top">
    <th scope="row" valign="top">
    <label for="rcp_business_city"><?php _e( 'Business City', 'rcp' ); ?></label>
    </th>
    <td>
    <input name="rcp_business_city" id="rcp_business_city" type="text" value="<?php echo esc_attr( $business_city ); ?>"/>
    <p class="description"><?php _e( 'The member\'s business city', 'rcp' ); ?></p>
    </td>
    </tr>
    <tr valign="top">
    <th scope="row" valign="top">
    <label for="rcp_business_postal code"><?php _e( 'Business Postal Code', 'rcp' ); ?></label>
    </th>
    <td>
    <input name="rcp_business_postal_code" id="rcp_business_postal_code" type="text" value="<?php echo esc_attr( $business_postal_code ); ?>"/>
    <p class="description"><?php _e( 'The member\'s business postal code', 'rcp' ); ?></p>
    </td>
    </tr>
    <tr valign="top">
    <th scope="row" valign="top">
    <label for="rcp_business_phone"><?php _e( 'Business Phone', 'rcp' ); ?></label>
    </th>
    <td>
    <input name="rcp_business_phone" id="rcp_business_code" type="text" value="<?php echo esc_attr( $business_phone ); ?>"/>
    <p class="description"><?php _e( 'The member\'s business phone', 'rcp' ); ?></p>
    </td>
    </tr>
    <?php
    }

    add_action( 'rcp_edit_member_after', 'pw_rcp_add_member_edit_fields' );


    /**
    * Determines if there are problems with the registration data submitted
    *
    */

    function pw_rcp_validate_user_fields_on_register( $posted ) {

    if( empty( $posted['rcp_address'] ) ) {
    rcp_errors()->add( 'invalid_address', __( 'Please enter your address', 'rcp' ), 'register' );
    }
    if( empty( $posted['rcp_city'] ) ) {
    rcp_errors()->add( 'invalid_city', __( 'Please enter your city', 'rcp' ), 'register' );
    }
    if( empty( $posted['rcp_province'] ) ) {
    rcp_errors()->add( 'invalid_province', __( 'Please enter your province', 'rcp' ), 'register' );
    }
    if( empty( $posted['rcp_postal_code'] ) ) {
    rcp_errors()->add( 'invalid_postal_code', __( 'Please enter your postal code', 'rcp' ), 'register' );
    }

    }

    add_action( 'rcp_form_errors', 'pw_rcp_validate_user_fields_on_register', 10 );

    /**
    * Stores the information submitted during registration
    *
    */
    function pw_rcp_save_user_fields_on_register( $posted, $user_id ) {

    if( ! empty( $posted['rcp_rmt_number'] ) ) {
    update_user_meta( $user_id, 'rcp_rmt_number', sanitize_text_field( $posted['rcp_rmt_number'] ) );
    }
    if( ! empty( $posted['rcp_address'] ) ) {
    update_user_meta( $user_id, 'rcp_address', sanitize_text_field( $posted['rcp_address'] ) );
    }
    if( ! empty( $posted['rcp_city'] ) ) {
    update_user_meta( $user_id, 'rcp_city', sanitize_text_field( $posted['rcp_city'] ) );
    }
    if( ! empty( $posted['rcp_province'] ) ) {
    update_user_meta( $user_id, 'province', sanitize_text_field( $posted['rcp_province'] ) );
    }
    if( ! empty( $posted['rcp_postal_code'] ) ) {
    update_user_meta( $user_id, 'rcp_postal_code', sanitize_text_field( $posted['rcp_postal_code'] ) );
    }
    if( ! empty( $posted['rcp_home_phone'] ) ) {
    update_user_meta( $user_id, 'rcp_home_phone', sanitize_text_field( $posted['rcp_home_phone'] ) );
    }
    if( ! empty( $posted['rcp_business_name'] ) ) {
    update_user_meta( $user_id, 'rcp_business_name', sanitize_text_field( $posted['rcp_business_name'] ) );
    }
    if( ! empty( $posted['rcp_business_address'] ) ) {
    update_user_meta( $user_id, 'rcp_business_address', sanitize_text_field( $posted['rcp_business_address'] ) );
    }
    if( ! empty( $posted['rcp_business_city'] ) ) {
    update_user_meta( $user_id, 'rcp_business_city', sanitize_text_field( $posted['rcp_business_city'] ) );
    }
    if( ! empty( $posted['rcp_business_postal_code'] ) ) {
    update_user_meta( $user_id, 'rcp_business_postal_code', sanitize_text_field( $posted['rcp_business_postal_code'] ) );
    }
    if( ! empty( $posted['rcp_business_phone'] ) ) {
    update_user_meta( $user_id, 'rcp_business_phone', sanitize_text_field( $posted['rcp_business_phone'] ) );
    }

    }

    add_action( 'rcp_form_processing', 'pw_rcp_save_user_fields_on_register', 10, 2 );

    /**
    * Stores the information submitted profile update
    *
    */
    function pw_rcp_save_user_fields_on_profile_save( $user_id ) {

    if( ! empty( $_POST['rcp_rmt_number'] ) ) {
    update_user_meta( $user_id, 'rcp_rmt_number', sanitize_text_field( $_POST['rcp_rmt_number'] ) );
    }
    if( ! empty( $_POST['rcp_address'] ) ) {
    update_user_meta( $user_id, 'rcp_address', sanitize_text_field( $_POST['rcp_address'] ) );
    }
    if( ! empty( $_POST['rcp_city'] ) ) {
    update_user_meta( $user_id, 'rcp_city', sanitize_text_field( $_POST['rcp_city'] ) );
    }
    if( ! empty( $_POST['rcp_province'] ) ) {
    update_user_meta( $user_id, 'rcp_province', sanitize_text_field( $_POST['rcp_province'] ) );
    }
    if( ! empty( $_POST['rcp_postal_code'] ) ) {
    update_user_meta( $user_id, 'rcp_postal_code', sanitize_text_field( $_POST['rcp_postal_code'] ) );
    }
    if( ! empty( $_POST['rcp_home_phone'] ) ) {
    update_user_meta( $user_id, 'rcp_home_phone', sanitize_text_field( $_POST['rcp_home_phone'] ) );
    }
    if( ! empty( $_POST['rcp_business_name'] ) ) {
    update_user_meta( $user_id, 'rcp_business_name', sanitize_text_field( $_POST['rcp_business_name'] ) );
    }
    if( ! empty( $_POST['rcp_business_address'] ) ) {
    update_user_meta( $user_id, 'rcp_business_address', sanitize_text_field( $_POST['rcp_business_address'] ) );
    }
    if( ! empty( $_POST['rcp_business_city'] ) ) {
    update_user_meta( $user_id, 'rcp_business_city', sanitize_text_field( $_POST['rcp_business_city'] ) );
    }
    if( ! empty( $_POST['rcp_business_postal_code'] ) ) {
    update_user_meta( $user_id, 'rcp_business_postal_code', sanitize_text_field( $_POST['rcp_business_postal_code'] ) );
    }
    if( ! empty( $_POST['rcp_business_phone'] ) ) {
    update_user_meta( $user_id, 'rcp_business_phone', sanitize_text_field( $_POST['rcp_business_phone'] ) );
    }

    }
    add_action( 'rcp_user_profile_updated', 'pw_rcp_save_user_fields_on_profile_save', 10 );
    add_action( 'rcp_edit_member', 'pw_rcp_save_user_fields_on_profile_save', 10 );

    function ag_rcp_import_custom_fields( $user_id, $user_data, $subscription_id, $status, $expiration, $row ) {

    $birthday = $row['birthday']; // Replace 'birthday' with your column heading name.

    if ( ! empty( $birthday ) ) {
    // Change 'birthday' to the user meta key you'd like to save the data as.
    update_user_meta( $user_id, 'birthday', sanitize_text_field( $birthday ) );
    }
    $address = $row['Address']; // Replace 'birthday' with your column heading name.
    if ( ! empty( $address ) ) {
    // Change 'birthday' to the user meta key you'd like to save the data as.
    update_user_meta( $user_id, 'Address', sanitize_text_field( $address ) );
    }
    $city = $row['City']; // Replace 'birthday' with your column heading name.
    if ( ! empty( $city ) ) {
    // Change 'birthday' to the user meta key you'd like to save the data as.
    update_user_meta( $user_id, 'City', sanitize_text_field( $city ) );
    }
    $province = $row['Province'];
    if ( ! empty( $province ) ) {
    // Change 'birthday' to the user meta key you'd like to save the data as.
    update_user_meta( $user_id, 'Province', sanitize_text_field( $province ) );
    }
    $postal_code = $row['Postal Code'];
    if ( ! empty( $postal_code ) ) {
    // Change 'birthday' to the user meta key you'd like to save the data as.
    update_user_meta( $user_id, 'Postal Code', sanitize_text_field( $postal_code ) );
    }
    $home_phone = $row['Home Phone'];
    if ( ! empty( $home_phone ) ) {
    // Change 'birthday' to the user meta key you'd like to save the data as.
    update_user_meta( $user_id, 'Home Phone', sanitize_text_field( $home_phone ) );
    }
    $business_name = $row['Business Name'];
    if ( ! empty( $business_name) ) {
    // Change 'birthday' to the user meta key you'd like to save the data as.
    update_user_meta( $user_id, 'Business Name', sanitize_text_field( $business_name ) );
    }
    $business_address = $row['Business Address'];
    if ( ! empty( $business_address ) ) {
    // Change 'birthday' to the user meta key you'd like to save the data as.
    update_user_meta( $user_id, 'Business Address', sanitize_text_field( $business_address ) );
    }
    $business_city = $row['Business city'];
    if ( ! empty( $business_city ) ) {
    // Change 'birthday' to the user meta key you'd like to save the data as.
    update_user_meta( $user_id, 'Business City', sanitize_text_field( $business_city ) );
    }
    $business_postal_code = $row['Business Postal Code'];
    if ( ! empty( $business_postal_code ) ) {
    // Change 'birthday' to the user meta key you'd like to save the data as.
    update_user_meta( $user_id, 'Business Postal Code', sanitize_text_field( $business_postal_code ) );
    }
    $business_phone = $row['Business Phone'];
    if ( ! empty( $business_phone ) ) {
    // Change 'birthday' to the user meta key you'd like to save the data as.
    update_user_meta( $user_id, 'Business Phone', sanitize_text_field( $business_phone ) );
    }
    $rmt_number = $row['RMT Number'];
    if ( ! empty( $rmt_number ) ) {
    // Change 'birthday' to the user meta key you'd like to save the data as.
    update_user_meta( $user_id, 'RMT Number', sanitize_text_field( $rmt_number ) );
    }
    }

    add_action( 'rcp_user_import_user_added', 'ag_rcp_import_custom_fields', 10, 6 );

    Cannot figure it out Parse Error functions.php
     
    #1

Share This Page

Monarch Social Sharing Plugin