HEX
Server: LiteSpeed
System: Linux server315.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: globfdxw (6114)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: /home/globfdxw/diasporameetsafrica.com/wp-content/plugins/wpforms-user-registration/src/Helper.php
<?php

namespace WPFormsUserRegistration;

use WP_User;

/**
 * Main Helper class.
 *
 * @since 2.0.0
 */
class Helper {

	/**
	 * Maybe set a user role.
	 *
	 * @since 2.0.0
	 *
	 * @param int $user_id User Id.
	 */
	public static function set_user_role( $user_id ) {

		$user = new WP_User( $user_id );

		// Check if we need to assign a new role.
		$role = $user->get( 'wpforms-role' );

		if ( $role && empty( $user->roles ) ) {
			$user->set_role( $role );
		}

		delete_user_meta( $user_id, 'wpforms-role' );
	}

	/**
	 * Check if the current request is a Gutenberg editor request.
	 *
	 * @since 2.8.0
	 *
	 * @return bool True if the current request is a Gutenberg editor request, false otherwise.
	 */
	public static function is_gb_editor(): bool {

		return (
			defined( 'REST_REQUEST' ) &&
			REST_REQUEST &&
			// phpcs:ignore WordPress.Security.NonceVerification.Recommended
			! empty( $_REQUEST['context'] ) && sanitize_text_field( wp_unslash( $_REQUEST['context'] ) ) === 'edit'
		);
	}
}