Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: admin notification after guest email verified #1320

Conversation

sapayth
Copy link
Member

@sapayth sapayth commented Dec 7, 2022

fix 494

Description: When an unregistered user proceeds to submit a guest post filling in name, email, and guest post fields, etc. when submit button is clicked confirmation email is sent for confirming the account. Then:

The confirmation email comes to the admin inbox but the post that was submitted along with the registration doesn't come.
How to reproduce:

Go to WPUF>Post Form>Cretae form>Settings>Submission Restriction> Check Enable Guest Post, Require Name and Email address, and Require Email Verification for Guests

Got to the page where the above post form is enabled> Fill the form with name, email, and necessary fields> Click Create post button

Summary by CodeRabbit

  • New Features

    • Enhanced flexibility in admin settings with dynamic properties support.
    • Added authorization checks for form saving and taxonomy retrieval.
    • New action hook for guest post email verification, including admin notification.
  • Bug Fixes

    • Improved reliability of conditional checks in form submission.
  • Refactor

    • Changed visibility of form data property to public for easier access.

@Rat01047
Copy link

Rat01047 commented Feb 6, 2023

Issue-1:
The gap between the Options and their fields is too large compared to other page's options

Scenario:
Go to > Settings > Emails > Guest Email > The gap between the Options and their fields is too large compared to other page's options

Screenshot given for reference:
image

@Rat01047
Copy link

Rat01047 commented Feb 6, 2023

Issue-2:
Clicking the Publish post link does not publish the post

Scenario:
WPUF FrontEnd > New Post > Submit a Post as Guest > Go to Guest Inbox > New Emails received > Go to "Please Confirm Your Email to Get the Post Published!" Email > Click the Publish Post Link > Redirects to another submitted Post > Post Submitted by Guest is still inactive and not published

Screenshot given for reference:
Email,
image

Post Still Inactive,
image

@Rat01047 Rat01047 added the bug label Feb 20, 2023
@sapayth sapayth added needs: developer feedback This PR needs developer feedback or code changes and removed needs: testing labels Jul 6, 2023
Copy link

coderabbitai bot commented Sep 18, 2024

Walkthrough

The pull request introduces several modifications across multiple classes. It adds the #[AllowDynamicProperties] annotation to the WPUF_Admin_Settings class, enabling dynamic property assignment. Security is enhanced in the Admin_Form_Builder_Ajax class with new authorization checks in the save_form and wpuf_get_post_taxonomies methods. Additionally, the visibility of the $data property in the Form class is changed to public, a new private property $form_fields is added to Frontend_Form_Ajax, and new methods are introduced in the Frontend_Form class to handle guest post email verification.

Changes

File Change Summary
admin/class-admin-settings.php Added #[AllowDynamicProperties] annotation to WPUF_Admin_Settings class.
includes/Ajax/Admin_Form_Builder_Ajax.php Added authorization checks in save_form and wpuf_get_post_taxonomies methods to verify user permissions.
includes/Admin/Forms/Form.php Changed $data property from private to public in Form class.
includes/Ajax/Frontend_Form_Ajax.php Added private property $form_fields and modified conditional checks in submit_post method.
includes/Frontend/Frontend_Form.php Added new action hook and methods for guest post email verification and notification.

Possibly related PRs

Poem

In the code where rabbits play,
New properties hop in to stay.
With checks to guard the forms we save,
A secure burrow, brave and brave!
So let us cheer, with joy we sing,
For changes bright that coding brings! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@sapayth sapayth added needs: testing and removed needs: developer feedback This PR needs developer feedback or code changes labels Sep 18, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 31c964d and 79bf57d.

Files selected for processing (3)
  • includes/Admin/Forms/Form.php (1 hunks)
  • includes/Ajax/Frontend_Form_Ajax.php (2 hunks)
  • includes/Frontend/Frontend_Form.php (3 hunks)
Additional comments not posted (4)
includes/Frontend/Frontend_Form.php (2)

332-377: LGTM!

The changes in the publish_guest_post function look good:

  • It correctly verifies the email before proceeding.
  • Handles the payment flow as expected.
  • Triggers an action hook for extensibility after successful email verification.

494-531: LGTM!

The new send_mail_to_admin_after_guest_mail_verified function looks good:

  • It is correctly hooked to the wpuf_guest_post_email_verified action.
  • Retrieves necessary data and loads form settings and fields.
  • Prevents sending duplicate notifications by checking email verification status.
  • Prepares the email content using the prepare_mail_body helper function.
  • Updates user meta to mark the email as verified.
includes/Ajax/Frontend_Form_Ajax.php (2)

23-27: LGTM!

The new $form_fields property is a useful addition to the Frontend_Form_Ajax class. It will help manage form data more effectively.


163-167: Good catch on using strict comparisons!

Switching from loose equality (==) to strict equality (===) is a best practice. It improves the reliability of the conditional checks by ensuring that both the value and type are considered.

@Rubaiyat-E-Mohammad
Copy link

Issue not solved. Not getting Post notification emails for guest post.

Ref Video: link

@Rubaiyat-E-Mohammad Rubaiyat-E-Mohammad added needs: developer feedback This PR needs developer feedback or code changes and removed needs: testing labels Sep 19, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 79bf57d and e69375e.

📒 Files selected for processing (1)
  • includes/Admin/Forms/Form.php (1 hunks)

@@ -21,7 +21,7 @@
/**
* @var array|\WP_Post|null
*/
private $data;
public $data;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Revert the visibility change of the $data property.

I strongly agree with the previous review comment. Changing the visibility of the $data property from private to public violates the principle of encapsulation and can lead to several issues:

  1. It allows uncontrolled access and modification of the $data property from outside the class.
  2. This can result in unexpected behavior and make the code harder to maintain and reason about.
  3. It increases the risk of introducing bugs or security vulnerabilities.
  4. It goes against best practices in object-oriented design.

Unless there is a compelling and well-documented reason for this change, it is strongly recommended to revert the visibility of the $data property back to private.

Apply this diff to revert the change:

-    public $data;
+    private $data;

If there is a specific need to access this property from outside the class, consider implementing getter and setter methods instead of making the property public. This would allow for controlled access and potential validation of the data.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public $data;
private $data;

@Rubaiyat-E-Mohammad Rubaiyat-E-Mohammad added QA Approved This PR is approved by the QA team Ready to Merge This PR is now ready to be merged and removed bug needs: developer feedback This PR needs developer feedback or code changes labels Sep 27, 2024
@sapayth sapayth merged commit e20b0ae into weDevsOfficial:develop Oct 10, 2024
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
QA Approved This PR is approved by the QA team Ready to Merge This PR is now ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants