View Categories

Social Proof Extension | Groundhogg

Document

Updating the Display of User’s Name in Groundhogg Proof Plugin

Before


After



💡

Purpose:

The purpose of this code is to display a user's name in a different format. Specifically, the modification involves showing the user's first name, and only the first initial of their last name (from groudhogg profile last name field) and add a dot beside it instead of the full last name.


💥

Note:

Before proceeding with the following steps, ensure you have a recent backup of the website. Directly editing PHP files may break the site if not done correctly. If you're unsure, please seek help from a professional or use a staging site to test changes first.


🗺️

Location:

Follow the steps below to locate the file where the code modification needs to be performed:

  1. Install the WP File Manager plugin (Plugin Link) on WordPress website.

  2. Navigate to the WP File Manager on your WordPress dashboard.

  3. Click on the wp-content folder to expand it.

  4. Inside wp-content, navigate to the plugins folder.

  5. In the plugins folder, locate and open the groundhogg-proof plugin folder.

  6. Within the groundhogg-proof folder, find and open the API folder.

  7. Inside the API folder, you'll find the proof-api-v4.php file.

  8. Right-click on the proof-api-v4.php file and select Code Editor from the context menu.

  9. Replace the code at lines 80 to 89 with the provided snippet code.



🔷

Code Snippet: PHP

$location = sprintf( __( '%s from %s', 'groundhogg-proof' ), $contact->get_first_name() . " " . substr($contact->get_last_name(), 0, 1) .".", $default_location );

				if ( $contact->city && $contact->region_code ) {
					$location = sprintf(
						__( "%s from %s, %s", 'groundhogg-proof' ),
						ucwords( $contact->get_first_name() . " " . substr($contact->get_last_name(), 0, 1)),
						ucwords( strtolower( $contact->city ) ),
						strtoupper( $contact->region_code )
					);
				}



Special Notes:

  • This code is added directly in the plugin's PHP file. It's important to be aware that updates to the plugin could remove this custom code. It's a good idea to keep a copy of this code and to check your customization after every plugin update to make sure it's still working.

  • This change is hard-coded, which means it cannot be modified from the WordPress dashboard. If you need to adjust it, you will have to change the code directly.

  • Don't forget to clear the cache on your site after you make changes to PHP files. Clearing the cache makes sure your changes take effect.

  • Remember to use best practices when you code and always check that the PHP syntax is correct. This helps prevent problems on your website.

Powered by BetterDocs

Schreibe einen Kommentar