• Resolved Matias G H

    (@mghextreme)


    So I decided to create some custom notification to the form.
    But I still want to use the same messages that are shown in the admin area, so that the user can still decide to change it as necessary.

    What code should I use on my PHP to get these variables?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Please have a look at https://codex.www.ads-software.com/Plugin_API/Action_Reference/admin_notices. If this does not answer your question, please ask for more specific help with examples of what you have tried and where you seem to be having problems with.

    Thread Starter Matias G H

    (@mghextreme)

    Sorry, themaster5_07, I thought it was correctly categorized.

    The content I want to get is from the admin page of a specific Contact Form 7 form. On each form you can set many messages for when the mail is sent, when it fail, when there is an incorrect field…

    I wanted t know if it is possible to do something like:

    get_wpcf7_message( formid, "wpcf7fail" );

    And it return something similar to

    "Failed to send your message. Please try later or contact the website administrator."

    or whatever message (in my case translated) that be there.

    If I still was not clear, please notice.
    I’m trying my best to help you help me.

    Thanks for the reply.

    @mghextreme,

    I am sorry, I missed the Contact Form 7 tag at first, my apologies.

    I think I can still help point you in the right direction to get you started though. There are two functions in /inclucdes/contact-form-functions.php that I think will help you. Plese see wpcf7_get_validation_error and wpcf7_get_message there is a catch to prevent using these if you are not in the current form though.

    EDIT: These only take one parameter and does not accept the form parameter. If you are using this outside of the form itself, you would have to first select your form. For that you might be able to use wpcf7_get_contact_form_by_title( $title )

    • This reply was modified 7 years, 6 months ago by themaster5_07. Reason: updated with more information
    Thread Starter Matias G H

    (@mghextreme)

    Thanks, @themaster5_07 ! It worked perfectly!

    For future people that reach this thread, I’ll leave here a brief explanation of what I did:

    echo do_shortcode('[contact-form-7 id="58" title="FormName"]');
    
    $m = array();
    $m[] = wpcf7_get_message( 'mail_sent_ok' );
    $m[] = wpcf7_get_message( 'mail_sent_ng' );
    $m[] = wpcf7_get_message( 'validation_error' );
    $m[] = wpcf7_get_message( 'spam' );

    Because I do the shortcode right before, I don’t need the wpcf7_get_contact_form_by_title( 'formName' ) before getting the messages.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How do I get the messages through PHP?’ is closed to new replies.