Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
1.1k views
in Q2A Core by

Inside admin/users I would like to know if there is a way to make the "Notice at top for first time visitors" appear only on the ask page to set a custom message to the first time users on this page only instead of on every page.

1 Answer

+2 votes
by

============================================================
One example (Notice at top for first time visitors)
============================================================

This is the method of using message to visitor.

Core Hack

qa-include/qa-page.php (L696 [case V1.5.4])

Before:

if (qa_opt('show_notice_visitor') && (!isset($topath)) && (!isset($_COOKIE['qa_noticed'])))
  $qa_content['notices'][]=qa_notice_form('visitor', qa_opt('notice_visitor'));

After:

if (qa_opt('show_notice_visitor') && (!isset($topath)) && (!isset($_COOKIE['qa_noticed'])))
  if($requestlower=='ask') // <- add this line
    $qa_content['notices'][]=qa_notice_form('visitor', qa_opt('notice_visitor'));

Settings

  1. admin -> users
  2. Check "Notice at top for first time visitors - HTML allowed:"
  3. Input "Be careful manners and ask."(example) in textbox

Test

Test after erasing COOKIE("qa_noticed") of your domain.

============================================================
Another example (Custom message on register form)
============================================================

This is the method of using message to users who registered.

Core Hack

qa-include/qa-page.php (L702 [case V1.5.4])

Before:

if (qa_opt('show_notice_welcome') && (qa_get_logged_in_flags() & QA_USER_FLAGS_WELCOME_NOTICE) )
  if ( ($requestlower!='confirm') && ($requestlower!='account') ) // let people finish registering in peace
    $qa_content['notices'][]=qa_notice_form('welcome', qa_opt('notice_welcome'));

After:

if (qa_opt('show_notice_welcome') && (qa_get_logged_in_flags() & QA_USER_FLAGS_WELCOME_NOTICE) )
  if ( ($requestlower!='confirm') && ($requestlower!='account') ) // let people finish registering in peace
    if ($requestlower=='ask') // <- add this line
      $qa_content['notices'][]=qa_notice_form('welcome', qa_opt('notice_welcome'));

Settings

  1. admin -> users
  2. Check "Custom message on register form - HTML allowed:"
  3. Input "Be careful manners and ask."(example) in textbox

Test

Register new user, and test by that new user. Since existing user's QA_USER_FLAGS_WELCOME_NOTICE is OFF, it is not fit for test.

...