Advertisement:

Author Topic: osclass recaptcha  (Read 583 times)

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
osclass recaptcha
« on: October 10, 2018, 03:52:02 am »
hey,
how to put a osclass recaptcha in a static page?
i have a static page and i want to have a recaptcha before submitting the form.
osclass recaptcha (osc_show_recaptcha()) is not working! or we have to do a core edit!
please help to do this,
theme bender,
thanks,

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: osclass recaptcha
« Reply #1 on: February 05, 2019, 12:17:43 pm »
Is there a solution for this?

WEBmods

  • Hero Member
  • *****
  • Posts: 937
  • github.com/webmods-croatia/love-osclass/ | patrick
Re: osclass recaptcha
« Reply #2 on: February 06, 2019, 12:14:46 am »
|-------------------------|
|    EDITED, WORKS!   |
|-------------------------|

Hello!

You would need a function that would verify the captcha on that specific page. Something like:

Code: [Select]
<?php
function wm_captcha_static_page() {
    if(
Params::getParam('page') == 'page' && Params::getParam('id') == 'YOUR PAGE ID') {
        if(
osc_recaptcha_private_key() != '') {
            if(!
osc_check_recaptcha()) {
                
osc_add_flash_error_message_m('The Recaptcha code is wrong') );
                
$this->redirectTo(osc_base_url(true)."?page=page&id=".Params::getParam('id'));
            }
        }
    }
}
osc_add_hook('init''wm_captcha_static_page');

Then you need to have a form with some hidden inputs:

Code: [Select]
<form class="nocsrf">
    <input type="hidden" name="page" value="page" /> <!-- IMPORTANT -->
    <input type="hidden" name="id" value="23" /> <!-- CHANGE ID! - IMPORTANT -->
    <input type="hidden" name="post_page_captcha" value="1" /> <!-- IMPORTANT -->
    <?php osc_show_recaptcha('register'); ?>
    <button type="submit" value="Submit">Submit</button>
</form>

Regards.
« Last Edit: March 06, 2019, 11:31:58 am by patrickFromCroatia »

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: osclass recaptcha
« Reply #3 on: February 07, 2019, 10:41:08 pm »
Hello!

You would need a function that would verify the captcha on that specific page. Something like:

Code: [Select]
<?php
function wm_captcha_static_page() {
    if(
Params::getParam('page') == 'page' && Params::getParam('id') == 'YOUR PAGE ID') {
        if(
osc_recaptcha_private_key() != '') {
            if(!
osc_check_recaptcha()) {
                
osc_add_flash_error_message_m('The Recaptcha code is wrong') );
                
$this->redirectTo(osc_base_url(true)."?page=page&id=".Params::getParam('id'));
            }
        }
    }
}
osc_add_hook('init''wm_captcha_static_page');

Regards.

Thanks a lot,
Im on my phone these days. I will test it and post the result after i reach my pc.
Thanks

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: osclass recaptcha
« Reply #4 on: February 08, 2019, 09:32:21 pm »
Hello!

You would need a function that would verify the captcha on that specific page. Something like:

Code: [Select]
<?php
function wm_captcha_static_page() {
    if(
Params::getParam('page') == 'page' && Params::getParam('id') == 'YOUR PAGE ID') {
        if(
osc_recaptcha_private_key() != '') {
            if(!
osc_check_recaptcha()) {
                
osc_add_flash_error_message_m('The Recaptcha code is wrong') );
                
$this->redirectTo(osc_base_url(true)."?page=page&id=".Params::getParam('id'));
            }
        }
    }
}
osc_add_hook('init''wm_captcha_static_page');

Regards.

@patrick,
i put page-id and put the function in functions.php but did not work!
« Last Edit: February 08, 2019, 09:34:05 pm by Sophia_OS »

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: osclass recaptcha
« Reply #5 on: March 06, 2019, 03:49:22 am »
Hello!

You would need a function that would verify the captcha on that specific page. Something like:

Code: [Select]
<?php
function wm_captcha_static_page() {
    if(
Params::getParam('page') == 'page' && Params::getParam('id') == 'YOUR PAGE ID') {
        if(
osc_recaptcha_private_key() != '') {
            if(!
osc_check_recaptcha()) {
                
osc_add_flash_error_message_m('The Recaptcha code is wrong') );
                
$this->redirectTo(osc_base_url(true)."?page=page&id=".Params::getParam('id'));
            }
        }
    }
}
osc_add_hook('init''wm_captcha_static_page');

Regards.


@patrickFromCroatia
thank you but your code does not work!
« Last Edit: March 06, 2019, 03:52:19 am by Sophia_OS »

WEBmods

  • Hero Member
  • *****
  • Posts: 937
  • github.com/webmods-croatia/love-osclass/ | patrick
Re: osclass recaptcha
« Reply #6 on: March 06, 2019, 11:32:33 am »
I edited the code and it's fully working.

Demo: http://148.251.207.178/osclass/plugins/demo/index.php?page=page&id=23

Regards.

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: osclass recaptcha
« Reply #7 on: March 08, 2019, 11:04:34 am »
|-------------------------|
|    EDITED, WORKS!   |
|-------------------------|

Hello!

You would need a function that would verify the captcha on that specific page. Something like:

Code: [Select]
<?php
function wm_captcha_static_page() {
    if(
Params::getParam('page') == 'page' && Params::getParam('id') == 'YOUR PAGE ID') {
        if(
osc_recaptcha_private_key() != '') {
            if(!
osc_check_recaptcha()) {
                
osc_add_flash_error_message_m('The Recaptcha code is wrong') );
                
$this->redirectTo(osc_base_url(true)."?page=page&id=".Params::getParam('id'));
            }
        }
    }
}
osc_add_hook('init''wm_captcha_static_page');

Then you need to have a form with some hidden inputs:

Code: [Select]
<form class="nocsrf">
    <input type="hidden" name="page" value="page" /> <!-- IMPORTANT -->
    <input type="hidden" name="id" value="23" /> <!-- CHANGE ID! - IMPORTANT -->
    <input type="hidden" name="post_page_captcha" value="1" /> <!-- IMPORTANT -->
    <?php osc_show_recaptcha('register'); ?>
    <button type="submit" value="Submit">Submit</button>
</form>

Regards.

hey patrickFromCroatia
'YOUR PAGE ID' and "23", both i put my page-id but it did not work,
would you please share us your static-page that works with recaptcha?
also i mention that my Permalinks is on. but i also tested with Permalinks off and also did not work!
thanks

WEBmods

  • Hero Member
  • *****
  • Posts: 937
  • github.com/webmods-croatia/love-osclass/ | patrick
Re: osclass recaptcha
« Reply #8 on: March 08, 2019, 08:59:54 pm »
Did you add that form? I have the exact code on my demo site whose link I provided and it works.

I edited the code and it's fully working.

Demo: http://148.251.207.178/osclass/plugins/demo/index.php?page=page&id=23

Regards.

Regards.

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: osclass recaptcha
« Reply #9 on: March 09, 2019, 03:09:38 am »
Did you add that form? I have the exact code on my demo site whose link I provided and it works.

I edited the code and it's fully working.

Demo: http://148.251.207.178/osclass/plugins/demo/index.php?page=page&id=23

Regards.

Regards.

Yeah i tested that page and it worked!
But unfortunately i couldn't make it.
Would you please share us exactly its code?
Thank you

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: osclass recaptcha
« Reply #10 on: April 10, 2019, 01:40:37 am »
@patrickFromCroatia
i tested your code again, it works!
maybe because i was using your old code,
Thank you very much!
« Last Edit: April 10, 2019, 04:49:25 am by Sophia_OS »