Okay
  Public Ticket #3759254
WP Hooks, object structure
Open

Comments

  • stefano started the conversation

    Good evening,

    I am trying to write a WordPress plugin that uses Amelia's hooks.

    Specifically, I added a custom field on an appointment, and would like to pre-fill it. It should contain the previous page visited or the referral anyways.

    I thought I could use "amelia_before_cf_added_filter" hook, but I would need to know how the $customField object is made (properties, methods etc.).

    Where could I look this up?

    Thank you

  •  1,499
    Uroš replied
     

    Good evening,

    To work with Amelia's hooks and filters like amelia_before_cf_added_filter, it's helpful to review the plugin's source code directly, as Amelia’s documentation does not always provide a detailed breakdown of each object’s structure. Here’s what you can do:

    1. Explore the Source Code: Navigate to the Amelia plugin folder in your WordPress installation (wp-content/plugins/ameliabooking/). Look for files related to custom fields, particularly under src/Infrastructure/WP/Filters. Here, you can usually find filter definitions and see how the $customField object is constructed and used.

    2. Debug the Object: If you need to quickly inspect the $customField object, try logging it using error_log() or var_dump(). For example:

       
      add_filter('amelia_before_cf_added_filter', 'custom_pre_fill_cf', 10, 1); function custom_pre_fill_cf($customField) { error_log(print_r($customField, true)); // Check the properties in the PHP error log return $customField; }

      This way, you can get a list of available properties and methods directly.

    Let me know if you need further assistance with specific parts of the code!

    Kind Regards, 

    Uros Jovanovic
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables