I wanted to modify the html code in listing-created-date.php but didn’t want to make changes to the file directly. What are my options, I did not see a hook for this.
I want to modify class-membership.php but could not find a hook for this in the HivePress Code Reference. Did I miss something, is there documentation for hooks specifically for the hivepress extension plugins?
Sorry for the delay. Yes, it’s possible to override files located in the “templates” sub-directory of HivePress and it’s extensions, e.g. for the listing-created-date.php:
You can overwrite only template parts using a child theme, but not a framework file. It all depends on what exactly you need to change in this file, but in 99% of cases, it can be customized using hooks, for example: hivepress/v1/routes
Please provide more details on what specific changes you need and we will try to provide more details (perhaps there is another way to make such changes).
I’m adding commands such as $wpdb->insert and modify/updating the postmeta table. I am also adding various commands like these throughout other functions in the class-membership.php file.
If possible describe the required functional changes, e.g. why adding $wpdb->insert is needed, I can recommend something depending on the desirable results. It’s better to use hooks if available or override template parts because any direct file changes will require disabling updates for HivePress or making these changes on every update.
The all-in-one solution is to use the hivepress/v1/routes hook to override the redirect and action functions for the routes (URLs which render templates) you want to customize, but replacing them completely will also cause an issue if the original functions in HivePress are updated someday.
Please check if it’s possible to change it in the UI, e.g. for the free membership plan or extra premium plans (e.g. you can create a free plan for everyone to select with a limit of 5, this would be a workaround).
This depends on when this code should run, is there a specific action or event? I can suggest a hook then which can be used to run this code via an external code snippet.
This is not possible to set in the UI. The UI View Limit option is for how many views the user receives. The 5 figure I am trying to set is how many views it would subtract from the View Limit from the user.
I would like to run this on line 159 in between $membership->set_view_limit… and elseif
I recommend checking workarounds, e.g. increase the actual average price for a single reveal 5x, otherwise editing the code directly is required.
You can try using this hook hivepress/v1/models/memebership/update_view_limit or hivepress/v1/models/membership/update but extra conditions may be required in the functions attached to these hooks to distinguish the initial update of the membership (when it’s created with a view limit) from the substraction.
I’ve reviewed the available hooks and understand that hooks like hivepress/v1/models/membership/update_{field_name} are dynamically generated based on the fields of the membership model.
Yes, but a few fields from the list seems to be related to the User model (so the hook will be different, with the “user” in its name). You can test any hook by adding var_dump() or error_log() to the callback and try adding a membership or performing any other action that should trigger the hook. Regarding the membership-specific fields, please check them in hivepress-memberships/includes/models/class-membership.php file.